Added to_str for Status
This commit is contained in:
14
src/conn.rs
14
src/conn.rs
@@ -4,7 +4,7 @@ use tokio::net::TcpStream;
|
||||
use tokio::prelude::*;
|
||||
use tokio_openssl::SslStream;
|
||||
|
||||
use crate::status;
|
||||
use crate::status::Status;
|
||||
|
||||
pub struct Connection {
|
||||
pub stream: SslStream<TcpStream>,
|
||||
@@ -14,8 +14,8 @@ pub struct Connection {
|
||||
impl Connection {
|
||||
pub async fn send_status(
|
||||
&mut self,
|
||||
stat: status::Status,
|
||||
meta: &str,
|
||||
stat: Status,
|
||||
meta: Option<&str>,
|
||||
) -> Result<(), io::Error> {
|
||||
self.send_body(stat, meta, None).await?;
|
||||
Ok(())
|
||||
@@ -23,10 +23,14 @@ pub async fn send_status(
|
||||
|
||||
pub async fn send_body(
|
||||
&mut self,
|
||||
stat: status::Status,
|
||||
meta: &str,
|
||||
stat: Status,
|
||||
meta: Option<&str>,
|
||||
body: Option<String>,
|
||||
) -> Result<(), io::Error> {
|
||||
let meta = match meta {
|
||||
Some(m) => m,
|
||||
None => &stat.to_str(),
|
||||
};
|
||||
let mut s = format!("{}\t{}\r\n", stat as u8, meta);
|
||||
if let Some(b) = body {
|
||||
s += &b;
|
||||
|
||||
Reference in New Issue
Block a user