mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-18 00:00:09 +02:00
io: add BufStream::with_capacity (#2125)
This commit is contained in:
@@ -33,6 +33,23 @@ impl<RW: AsyncRead + AsyncWrite> BufStream<RW> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a `BufStream` with the specified [`BufReader`] capacity and [`BufWriter`]
|
||||
/// capacity.
|
||||
///
|
||||
/// See the documentation for those types and [`BufStream`] for details.
|
||||
pub fn with_capacity(
|
||||
reader_capacity: usize,
|
||||
writer_capacity: usize,
|
||||
stream: RW,
|
||||
) -> BufStream<RW> {
|
||||
BufStream {
|
||||
inner: BufReader::with_capacity(
|
||||
reader_capacity,
|
||||
BufWriter::with_capacity(writer_capacity, stream),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets a reference to the underlying I/O object.
|
||||
///
|
||||
/// It is inadvisable to directly read from the underlying I/O object.
|
||||
|
||||
Reference in New Issue
Block a user