On this page
Struct std::io::Empty
#[non_exhaustive]pub struct Empty;
Empty
ignores any data written via Write
, and will always be empty (returning zero bytes) when read via Read
.
This struct is generally created by calling empty()
. Please see the documentation of empty()
for more details.
Trait Implementations
impl BufRead for Empty
fn fill_buf(&mut self) -> Result<&[u8]>
Returns the contents of the internal buffer, filling it with more data from the inner reader if it is empty. Read more
fn consume(&mut self, _n: usize)
Tells this buffer that
amt
bytes have been consumed from the buffer, so they should no longer be returned in calls to read
. Read more
fn has_data_left(&mut self) -> Result<bool>
🔬This is a nightly-only experimental API. (
buf_read_has_data_left
#86423)
Check if the underlying
Read
has any data left to be read. Read more
fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize>
fn read_line(&mut self, buf: &mut String) -> Result<usize>
Read all bytes until a newline (the
0xA
byte) is reached, and append them to the provided String
buffer. Read more
fn split(self, byte: u8) -> Split<Self> ⓘ
where
Self: Sized,
Returns an iterator over the contents of this reader split on the byte
byte
. Read more
fn lines(self) -> Lines<Self> ⓘ
where
Self: Sized,
Returns an iterator over the lines of this reader. Read more
impl Clone for Empty
fn clone(&self) -> Empty ⓘ
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more
impl Debug for Empty
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the value using the given formatter. Read more
impl Default for Empty
impl Read for Empty
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
fn read_buf(&mut self, _cursor: BorrowedCursor<'_>) -> Result<()>
🔬This is a nightly-only experimental API. (
read_buf
#78485)
Pull some bytes from this source into the specified buffer. Read more
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
Like
read
, except that it reads into a slice of buffers. Read more
fn is_read_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
#69941)
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>
Read all bytes until EOF in this source, placing them into
buf
. Read more
fn read_to_string(&mut self, buf: &mut String) -> Result<usize>
Read all bytes until EOF in this source, appending them to
buf
. Read more
fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
Read the exact number of bytes required to fill
buf
. Read more
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<()>
🔬This is a nightly-only experimental API. (
read_buf
#78485)
Read the exact number of bytes required to fill
cursor
. Read more
fn by_ref(&mut self) -> &mut Self
where
Self: Sized,
Creates a “by reference” adaptor for this instance of
Read
. Read more
fn bytes(self) -> Bytes<Self> ⓘ
where
Self: Sized,
fn chain<R: Read>(self, next: R) -> Chain<Self, R> ⓘ
where
Self: Sized,
Creates an adapter which will chain this stream with another. Read more
fn take(self, limit: u64) -> Take<Self> ⓘ
where
Self: Sized,
Creates an adapter which will read at most
limit
bytes from it. Read more
impl Seek for Empty
fn seek(&mut self, _pos: SeekFrom) -> Result<u64>
Seek to an offset, in bytes, in a stream. Read more
fn stream_len(&mut self) -> Result<u64>
🔬This is a nightly-only experimental API. (
seek_stream_len
#59359)
Returns the length of this stream (in bytes). Read more
fn stream_position(&mut self) -> Result<u64>
Returns the current seek position from the start of the stream. Read more
fn rewind(&mut self) -> Result<()>
Rewind to the beginning of a stream. Read more
impl Write for &Empty
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this writer, returning how many bytes were written. Read more
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize>
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
#69941)
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<()>
Attempts to write an entire buffer into this writer. Read more
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
🔬This is a nightly-only experimental API. (
write_all_vectored
#70436)
Attempts to write multiple buffers into this writer. Read more
fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<()>
Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self
where
Self: Sized,
Creates a “by reference” adapter for this instance of
Write
. Read more
impl Write for Empty
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this writer, returning how many bytes were written. Read more
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize>
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
#69941)
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<()>
Attempts to write an entire buffer into this writer. Read more
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
🔬This is a nightly-only experimental API. (
write_all_vectored
#70436)
Attempts to write multiple buffers into this writer. Read more
fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<()>
Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self
where
Self: Sized,
Creates a “by reference” adapter for this instance of
Write
. Read more
impl Copy for Empty
Auto Trait Implementations
impl RefUnwindSafe for Empty
impl Send for Empty
impl Sync for Empty
impl Unpin for Empty
impl UnwindSafe for Empty
Blanket Implementations
impl<T> Any for T
where
T: 'static + ?Sized,
impl<T> Borrow<T> for T
where
T: ?Sized,
impl<T> BorrowMut<T> for T
where
T: ?Sized,
impl<T> From<T> for T
fn from(t: T) -> T
Returns the argument unchanged.
impl<T, U> Into<U> for T
where
U: From<T>,
fn into(self) -> U
Calls U::from(self)
.
That is, this conversion is whatever the implementation of From<T> for U
chooses to do.
impl<T> ToOwned for T
where
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T, U> TryFrom<U> for T
where
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
Performs the conversion.
impl<T, U> TryInto<U> for T
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
Performs the conversion.
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/io/struct.Empty.html