mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-24 00:00:11 +02:00
codec: add FramedWrite::with_capacity (#7493)
This commit is contained in:
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user