pub trait Framer {
type Head<'buf>;
fn parse<'buf>(&mut self, buf: &'buf [u8]) -> Option<(Self::Head<'buf>, usize)>;
fn body_len(head: &Self::Head<'_>) -> u32;
}
pub struct PassthroughFramer;
impl Framer for PassthroughFramer {
type Head<'buf> = ();
fn parse(&mut self, buf: &[u8]) -> Option<((), usize)> {
if buf.is_empty() {
None
} else {
Some(((), buf.len()))
}
}
fn body_len(_: &()) -> u32 {
0
}
}