1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
use bytes::Bytes; #[derive(Debug, Clone)] pub enum StatusCode { S200, CE400, } impl From<StatusCode> for Bytes { fn from(s: StatusCode) -> Self { match s { StatusCode::S200 => Bytes::from_static(b"200"), StatusCode::CE400 => Bytes::from_static(b"400"), } } } #[derive(Debug, Clone)] pub enum ReasonPhrase { Ok, } impl From<ReasonPhrase> for Bytes { fn from(r: ReasonPhrase) -> Self { match r { ReasonPhrase::Ok => Bytes::from_static(&[79u8, 75]), } } } pub fn get_reason_phrase_by_status_code(s: &StatusCode) -> Option<ReasonPhrase> { match s { StatusCode::S200 => Some(ReasonPhrase::Ok), _ => None, } }