pub struct AssumeUninitRead<R>(/* private fields */);Expand description
A wrapper that asserts a reader upholds the UninitRead contract.
Use this to wrap a reader from a third-party crate that is known to be
well-behaved (i.e., it doesn’t read from the buffer before writing to it)
but does not implement UninitRead itself.
Implementations§
Source§impl<R> AssumeUninitRead<R>
impl<R> AssumeUninitRead<R>
Sourcepub const unsafe fn assume_uninit_read(reader: R) -> Self
pub const unsafe fn assume_uninit_read(reader: R) -> Self
Wraps a reader, asserting that it adheres to the UninitRead contract.
§Safety
By calling this function, the caller guarantees that the Read and/or
AsyncRead implementation of R will not read from any part of the
provided buffer that has not been written to by the implementation
itself within the same call.
Sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Unwraps this AssumeUninitRead, returning the underlying reader.
Trait Implementations§
Source§impl<R> AsMut<R> for AssumeUninitRead<R>
impl<R> AsMut<R> for AssumeUninitRead<R>
Source§impl<R> AsRef<R> for AssumeUninitRead<R>
impl<R> AsRef<R> for AssumeUninitRead<R>
Source§impl<R: AsyncBufRead> AsyncBufRead for AssumeUninitRead<R>
impl<R: AsyncBufRead> AsyncBufRead for AssumeUninitRead<R>
Source§impl<R: AsyncRead> AsyncRead for AssumeUninitRead<R>
impl<R: AsyncRead> AsyncRead for AssumeUninitRead<R>
Source§impl<R: AsyncSeek> AsyncSeek for AssumeUninitRead<R>
impl<R: AsyncSeek> AsyncSeek for AssumeUninitRead<R>
Source§impl<R: AsyncWrite> AsyncWrite for AssumeUninitRead<R>
impl<R: AsyncWrite> AsyncWrite for AssumeUninitRead<R>
Source§fn 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 moreSource§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize>>
Attempt to write bytes from
bufs into the object using vectored
IO operations. Read moreSource§impl<R: BufRead> BufRead for AssumeUninitRead<R>
impl<R: BufRead> BufRead for AssumeUninitRead<R>
Source§fn fill_buf(&mut self) -> Result<&[u8]>
fn fill_buf(&mut self) -> Result<&[u8]>
Returns the contents of the internal buffer, filling it with more data, via
Read methods, if empty. Read moreSource§fn consume(&mut self, amount: usize)
fn consume(&mut self, amount: usize)
Marks the given
amount of additional bytes from the internal buffer as having been read.
Subsequent calls to read only return bytes that have not been marked as read. Read moreSource§fn skip_until(&mut self, byte: u8) -> Result<usize>
fn skip_until(&mut self, byte: u8) -> Result<usize>
Skips all bytes until the delimiter
byte or EOF is reached. Read moreSource§fn read_line(&mut self, buf: &mut String) -> Result<usize>
fn read_line(&mut self, buf: &mut String) -> Result<usize>
Reads all bytes until a newline (the
0xA byte) is reached, and append
them to the provided String buffer. Read moreSource§fn has_data_left(&mut self) -> Result<bool, Error>
fn has_data_left(&mut self) -> Result<bool, Error>
🔬This is a nightly-only experimental API. (
buf_read_has_data_left)Checks if there is any data left to be
read. Read moreSource§impl<R: Clone> Clone for AssumeUninitRead<R>
impl<R: Clone> Clone for AssumeUninitRead<R>
Source§impl<R: Debug> Debug for AssumeUninitRead<R>
impl<R: Debug> Debug for AssumeUninitRead<R>
Source§impl<R: Display> Display for AssumeUninitRead<R>
impl<R: Display> Display for AssumeUninitRead<R>
Source§impl<R: Hash> Hash for AssumeUninitRead<R>
impl<R: Hash> Hash for AssumeUninitRead<R>
Source§impl<R: Ord> Ord for AssumeUninitRead<R>
impl<R: Ord> Ord for AssumeUninitRead<R>
Source§impl<R: PartialEq> PartialEq for AssumeUninitRead<R>
impl<R: PartialEq> PartialEq for AssumeUninitRead<R>
Source§impl<R: PartialOrd> PartialOrd for AssumeUninitRead<R>
impl<R: PartialOrd> PartialOrd for AssumeUninitRead<R>
Source§impl<R: Read> Read for AssumeUninitRead<R>
impl<R: Read> Read for AssumeUninitRead<R>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning
how many bytes were read. Read more
Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
Like
read, except that it reads into a slice of buffers. Read moreSource§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>
Reads all bytes until EOF in this source, placing them into
buf. Read moreSource§fn read_to_string(&mut self, buf: &mut String) -> Result<usize>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize>
Reads all bytes until EOF in this source, appending them to
buf. Read moreSource§fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
Reads the exact number of bytes required to fill
buf. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector)Source§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf)Pull some bytes from this source into the specified buffer. Read more
Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf)Reads the exact number of bytes required to fill
cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Creates a “by reference” adapter for this instance of
Read. Read moreSource§impl<R: Seek> Seek for AssumeUninitRead<R>
impl<R: Seek> Seek for AssumeUninitRead<R>
Source§fn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
Seek to an offset, in bytes, in a stream. Read more
Source§fn stream_position(&mut self) -> Result<u64>
fn stream_position(&mut self) -> Result<u64>
Returns the current seek position from the start of the stream. Read more
Source§impl<R: Write> Write for AssumeUninitRead<R>
impl<R: Write> Write for AssumeUninitRead<R>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Writes a buffer into this writer, returning how many bytes were written. Read more
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flushes this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
Source§fn write_all(&mut self, buf: &[u8]) -> Result<()>
fn write_all(&mut self, buf: &[u8]) -> Result<()>
Attempts to write an entire buffer into this writer. Read more
Source§fn write_fmt(&mut self, args: Arguments<'_>) -> Result<()>
fn write_fmt(&mut self, args: Arguments<'_>) -> Result<()>
Writes a formatted string into this writer, returning any error
encountered. Read more
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector)impl<R: Copy> Copy for AssumeUninitRead<R>
impl<R: Eq> Eq for AssumeUninitRead<R>
impl<R> UninitRead for AssumeUninitRead<R>
Auto Trait Implementations§
impl<R> Freeze for AssumeUninitRead<R>where
R: Freeze,
impl<R> RefUnwindSafe for AssumeUninitRead<R>where
R: RefUnwindSafe,
impl<R> Send for AssumeUninitRead<R>where
R: Send,
impl<R> Sync for AssumeUninitRead<R>where
R: Sync,
impl<R> Unpin for AssumeUninitRead<R>where
R: Unpin,
impl<R> UnwindSafe for AssumeUninitRead<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<R> AsyncBufReadExt for Rwhere
R: AsyncBufRead + ?Sized,
impl<R> AsyncBufReadExt for Rwhere
R: AsyncBufRead + ?Sized,
Source§fn fill_buf(&mut self) -> FillBuf<'_, Self>where
Self: Unpin,
fn fill_buf(&mut self) -> FillBuf<'_, Self>where
Self: Unpin,
Returns the contents of the internal buffer, filling it with more data if empty. Read more
Source§fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8>,
) -> ReadUntilFuture<'a, Self>where
Self: Unpin,
fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8>,
) -> ReadUntilFuture<'a, Self>where
Self: Unpin,
Source§fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLineFuture<'a, Self>where
Self: Unpin,
fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLineFuture<'a, Self>where
Self: Unpin,
Reads all bytes and appends them into
buf until a newline (the 0xA byte) or EOF is found. Read moreSource§impl<R> AsyncReadExt for R
impl<R> AsyncReadExt for R
Source§fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self>where
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self>where
Self: Unpin,
Reads some bytes from the byte stream. Read more
Source§fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectoredFuture<'a, Self>where
Self: Unpin,
fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectoredFuture<'a, Self>where
Self: Unpin,
Source§fn read_to_end<'a>(
&'a mut self,
buf: &'a mut Vec<u8>,
) -> ReadToEndFuture<'a, Self>where
Self: Unpin,
fn read_to_end<'a>(
&'a mut self,
buf: &'a mut Vec<u8>,
) -> ReadToEndFuture<'a, Self>where
Self: Unpin,
Source§fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToStringFuture<'a, Self>where
Self: Unpin,
fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToStringFuture<'a, Self>where
Self: Unpin,
Source§fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self>where
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self>where
Self: Unpin,
Reads the exact number of bytes required to fill
buf. Read moreSource§fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
Creates an adapter which will read at most
limit bytes from it. Read moreSource§impl<S> AsyncSeekExt for S
impl<S> AsyncSeekExt for S
Source§impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
Source§fn write<'a>(&'a mut self, buf: &'a [u8]) -> WriteFuture<'a, Self>where
Self: Unpin,
fn write<'a>(&'a mut self, buf: &'a [u8]) -> WriteFuture<'a, Self>where
Self: Unpin,
Writes some bytes into the byte stream. Read more
Source§fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectoredFuture<'a, Self>where
Self: Unpin,
fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectoredFuture<'a, Self>where
Self: Unpin,
Source§fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAllFuture<'a, Self>where
Self: Unpin,
fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAllFuture<'a, Self>where
Self: Unpin,
Writes an entire buffer into the byte stream. Read more
Source§fn flush(&mut self) -> FlushFuture<'_, Self>where
Self: Unpin,
fn flush(&mut self) -> FlushFuture<'_, Self>where
Self: Unpin,
Flushes the stream to ensure that all buffered contents reach their destination. Read more
Source§fn boxed_writer<'a>(self) -> Pin<Box<dyn AsyncWrite + Send + 'a>>
fn boxed_writer<'a>(self) -> Pin<Box<dyn AsyncWrite + Send + 'a>>
Boxes the writer and changes its type to
dyn AsyncWrite + Send + 'a. Read moreSource§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<R> UninitAsyncReadExt for R
impl<R> UninitAsyncReadExt for R
Source§impl<R> UninitSyncReadExt for R
impl<R> UninitSyncReadExt for R
Source§fn read_uninit<'buf>(
&mut self,
buf: &'buf mut [MaybeUninit<u8>],
) -> Result<&'buf [u8], Error>
fn read_uninit<'buf>( &mut self, buf: &'buf mut [MaybeUninit<u8>], ) -> Result<&'buf [u8], Error>
Pulls some bytes from this source into the provided uninitialized buffer. Read more
Source§fn read_uninit_exact<'buf>(
&mut self,
buf: &'buf mut [MaybeUninit<u8>],
) -> Result<&'buf [u8], Error>
fn read_uninit_exact<'buf>( &mut self, buf: &'buf mut [MaybeUninit<u8>], ) -> Result<&'buf [u8], Error>
Reads the exact number of bytes required to fill
buf from this source. Read more