Added to_str for Status

This commit is contained in:
int 80h
2020-05-12 19:45:21 -04:00
parent 51a78ad04a
commit ea2c67c72f
5 changed files with 55 additions and 22 deletions

View File

@@ -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;