mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-25 12:00:35 +00:00
codec: add FramedWrite::with_capacity
(#7493)
This commit is contained in:
parent
ad2e19ffe1
commit
1bc50825f3
@ -47,6 +47,21 @@ where
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new `FramedWrite` with the given `encoder` and a buffer of `capacity`
|
||||
/// initial size.
|
||||
pub fn with_capacity(inner: T, encoder: E, capacity: usize) -> FramedWrite<T, E> {
|
||||
FramedWrite {
|
||||
inner: FramedImpl {
|
||||
inner,
|
||||
codec: encoder,
|
||||
state: WriteFrame {
|
||||
buffer: BytesMut::with_capacity(capacity),
|
||||
backpressure_boundary: capacity,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E> FramedWrite<T, E> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user