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
pub mod http1;
use gateway_common::{error::BoxError, FusenFuture};

#[derive(Clone, Debug)]
pub enum ProtocolType {
    HTTP,
    HTTP2,
    HTTP3,
}
#[derive(Clone)]
pub struct Protocol {
    p_type: ProtocolType,
    port: String,
}

impl Protocol {
    pub fn new(p_type: ProtocolType, port: String) -> Self {
        Self { p_type, port }
    }

    pub fn get_port(&self) -> &String {
        &self.port
    }
    pub fn get_type(&self) -> &ProtocolType {
        &self.p_type
    }
}

pub trait StreamHandler: Send + Sync {
    fn handler(self) -> FusenFuture<Result<(), BoxError>>;

    fn boxed(self) -> Box<dyn StreamHandler>;
}