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