feat: add new_from_leftover on Framed

This commit is contained in:
Benoît CORTIER 2023-10-28 20:51:28 -04:00 committed by Benoît Cortier
parent f834305563
commit 40740169e0
2 changed files with 10 additions and 5 deletions

View file

@ -66,9 +66,13 @@ where
S: StreamWrapper,
{
pub fn new(stream: S::InnerStream) -> Self {
Self::new_with_leftover(stream, BytesMut::new())
}
pub fn new_with_leftover(stream: S::InnerStream, leftover: BytesMut) -> Self {
Self {
stream: S::from_inner(stream),
buf: BytesMut::new(),
buf: leftover,
}
}