Struct BufStream
pub struct BufStream<RW> { /* private fields */ }
Wraps a type that is AsyncWrite and AsyncRead, and buffers its input and output.
It can be excessively inefficient to work directly with something that implements AsyncWrite
and AsyncRead. For example, every write, however small, has to traverse the syscall
interface, and similarly, every read has to do the same. The BufWriter and BufReader
types aid with these problems respectively, but do so in only one direction. BufStream wraps
one in the other so that both directions are buffered. See their documentation for details.
Implementations
impl<RW: AsyncRead + AsyncWrite> BufStream<RW>
fn new(stream: RW) -> BufStream<RW>Wraps a type in both
BufWriterandBufReader.See the documentation for those types and
BufStreamfor details.fn with_capacity(reader_capacity: usize, writer_capacity: usize, stream: RW) -> BufStream<RW>Creates a
BufStreamwith the specifiedBufReadercapacity andBufWritercapacity.See the documentation for those types and
BufStreamfor details.fn get_ref(&self) -> &RWGets a reference to the underlying I/O object.
It is inadvisable to directly read from the underlying I/O object.
fn get_mut(&mut self) -> &mut RWGets a mutable reference to the underlying I/O object.
It is inadvisable to directly read from the underlying I/O object.
fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut RW>Gets a pinned mutable reference to the underlying I/O object.
It is inadvisable to directly read from the underlying I/O object.
fn into_inner(self) -> RWConsumes this
BufStream, returning the underlying I/O object.Note that any leftover data in the internal buffer is lost.
Trait Implementations
impl<'__pin, RW> Unpin for BufStream<RW>
where
PinnedFieldsOf<__Origin<'__pin, RW>>: Unpin,
impl<RW> From<BufReader<BufWriter<RW>>> for BufStream<RW>
fn from(b: BufReader<BufWriter<RW>>) -> Self
impl<RW> From<BufWriter<BufReader<RW>>> for BufStream<RW>
fn from(b: BufWriter<BufReader<RW>>) -> Self
impl<RW: AsyncRead + AsyncWrite + AsyncSeek> AsyncSeek for BufStream<RW>
fn start_seek(self: Pin<&mut Self>, position: SeekFrom) -> Result<()>fn poll_complete(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<u64>>
impl<RW: AsyncRead + AsyncWrite> AsyncBufRead for BufStream<RW>
fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<&[u8]>>fn consume(self: Pin<&mut Self>, amt: usize)
impl<RW: AsyncRead + AsyncWrite> AsyncRead for BufStream<RW>
fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll<Result<()>>
impl<RW: AsyncRead + AsyncWrite> AsyncWrite for BufStream<RW>
fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>>fn poll_write_vectored(self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>]) -> Poll<Result<usize>>fn is_write_vectored(&self) -> boolfn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
impl<RW: Debug> Debug for BufStream<RW>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl<RW> Freeze for BufStream<RW>
where
BufReader<BufWriter<RW>>: Freeze,
impl<RW> RefUnwindSafe for BufStream<RW>
where
BufReader<BufWriter<RW>>: RefUnwindSafe,
impl<RW> Send for BufStream<RW>
where
BufReader<BufWriter<RW>>: Send,
impl<RW> Sync for BufStream<RW>
where
BufReader<BufWriter<RW>>: Sync,
impl<RW> UnsafeUnpin for BufStream<RW>
where
BufReader<BufWriter<RW>>: UnsafeUnpin,
impl<RW> UnwindSafe for BufStream<RW>
where
BufReader<BufWriter<RW>>: UnwindSafe,
Blanket Implementations
impl<R> AsyncBufReadExt for BufStream<RW>
where
R: AsyncBufRead + ?Sized,
impl<R> AsyncReadExt for BufStream<RW>
where
R: AsyncRead + ?Sized,
impl<S> AsyncSeekExt for BufStream<RW>
where
S: AsyncSeek + ?Sized,
impl<T> Any for BufStream<RW>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for BufStream<RW>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for BufStream<RW>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for BufStream<RW>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for BufStream<RW>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for BufStream<RW>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for BufStream<RW>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>