codec: add FramedWrite::with_capacity (#7493)

This commit is contained in:
Lucas Black
2025-08-01 11:23:22 +02:00
committed by GitHub
parent ad2e19ffe1
commit 1bc50825f3
+15
View File
@@ -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> {