pub struct BufStream<RW> { /* private fields */ }
Expand description
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
sourceimpl<RW: AsyncRead + AsyncWrite> BufStream<RW>
impl<RW: AsyncRead + AsyncWrite> BufStream<RW>
sourcepub fn with_capacity(
reader_capacity: usize,
writer_capacity: usize,
stream: RW
) -> BufStream<RW>
pub fn with_capacity(
reader_capacity: usize,
writer_capacity: usize,
stream: RW
) -> BufStream<RW>
sourcepub fn get_ref(&self) -> &RW
pub fn get_ref(&self) -> &RW
Gets a reference to the underlying I/O object.
It is inadvisable to directly read from the underlying I/O object.
sourcepub fn get_mut(&mut self) -> &mut RW
pub fn get_mut(&mut self) -> &mut RW
Gets a mutable reference to the underlying I/O object.
It is inadvisable to directly read from the underlying I/O object.
sourcepub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut RW>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut RW>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Gets a pinned mutable reference to the underlying I/O object.
It is inadvisable to directly read from the underlying I/O object.
sourcepub fn into_inner(self) -> RW
pub fn into_inner(self) -> RW
Consumes this BufStream
, returning the underlying I/O object.
Note that any leftover data in the internal buffer is lost.
Trait Implementations
sourceimpl<RW: AsyncRead + AsyncWrite> AsyncBufRead for BufStream<RW>
impl<RW: AsyncRead + AsyncWrite> AsyncBufRead for BufStream<RW>
sourceimpl<RW: AsyncRead + AsyncWrite> AsyncRead for BufStream<RW>
impl<RW: AsyncRead + AsyncWrite> AsyncRead for BufStream<RW>
sourcefn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8]
) -> Poll<Result<usize>>
fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8]
) -> Poll<Result<usize>>
Attempts to read from the AsyncRead
into buf
. Read more
sourceunsafe fn prepare_uninitialized_buffer(
&self,
buf: &mut [MaybeUninit<u8>]
) -> bool
unsafe fn prepare_uninitialized_buffer(
&self,
buf: &mut [MaybeUninit<u8>]
) -> bool
Prepares an uninitialized buffer to be safe to pass to read
. Returns
true
if the supplied buffer was zeroed out. Read more
sourceimpl<RW: AsyncRead + AsyncWrite> AsyncWrite for BufStream<RW>
impl<RW: AsyncRead + AsyncWrite> AsyncWrite for BufStream<RW>
sourcefn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize>>
fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize>>
Attempt to write bytes from buf
into the object. Read more
sourcefn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
Attempts to flush the object, ensuring that any buffered data reach their destination. Read more
impl<'__pin, RW> Unpin for BufStream<RW> where
__Origin<'__pin, RW>: Unpin,
Auto Trait Implementations
impl<RW> RefUnwindSafe for BufStream<RW> where
RW: RefUnwindSafe,
impl<RW> Send for BufStream<RW> where
RW: Send,
impl<RW> Sync for BufStream<RW> where
RW: Sync,
impl<RW> UnwindSafe for BufStream<RW> where
RW: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more