wetstring/src/request_response.rs

23 lines
477 B
Rust

pub trait Request {
type Response;
fn new() -> Self;
fn push_bytes(&mut self, bytes: &[u8]);
fn parse(&mut self) -> RequestParseResult<Self, Self::Response>
where
Self: Sized,
Self::Response: Response;
}
pub trait Response {
fn to_bytes(self) -> Vec<u8>;
}
pub type ProcessRequest<Req, Res> = fn(request: &Req) -> Res;
pub enum RequestParseResult<Req: Request, Res: Response> {
Incomplete,
Complete(Req),
Invalid(Res),
}