feat: add new_from_leftover on Framed

This commit is contained in:
Benoît CORTIER
2023-10-30 18:24:00 -04:00
committed by Benoît Cortier
parent f834305563
commit 40740169e0
2 changed files with 10 additions and 5 deletions
+5 -1
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,
}
}
+5 -4
View File
@@ -10,10 +10,11 @@ pub struct Framed<S> {
impl<S> Framed<S> {
pub fn new(stream: S) -> Self {
Self {
stream,
buf: BytesMut::new(),
}
Self::new_with_leftover(stream, BytesMut::new())
}
pub fn new_with_leftover(stream: S, leftover: BytesMut) -> Self {
Self { stream, buf: leftover }
}
pub fn into_inner(self) -> (S, BytesMut) {