pub struct AllowStdIo<T>(/* private fields */);
Available on crate feature
io
only.Expand description
A simple wrapper type which allows types which implement only
implement std::io::Read
or std::io::Write
to be used in contexts which expect an AsyncRead
or AsyncWrite
.
If these types issue an error with the kind io::ErrorKind::WouldBlock
,
it is expected that they will notify the current task on readiness.
Synchronous std
types should not issue errors of this kind and
are safe to use in this context. However, using these types with
AllowStdIo
will cause the event loop to block, so they should be used
with care.
Implementations§
Source§impl<T> AllowStdIo<T>
impl<T> AllowStdIo<T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes self and returns the contained IO object.
Trait Implementations§
Source§impl<T> AsyncBufRead for AllowStdIo<T>where
T: BufRead,
impl<T> AsyncBufRead for AllowStdIo<T>where
T: BufRead,
Source§impl<T> AsyncRead for AllowStdIo<T>where
T: Read,
impl<T> AsyncRead for AllowStdIo<T>where
T: Read,
Source§impl<T> AsyncSeek for AllowStdIo<T>where
T: Seek,
impl<T> AsyncSeek for AllowStdIo<T>where
T: Seek,
Source§impl<T> AsyncWrite for AllowStdIo<T>where
T: Write,
impl<T> AsyncWrite for AllowStdIo<T>where
T: Write,
Source§fn poll_write(
self: Pin<&mut Self>,
_: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, _: &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>,
_: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize>>
fn poll_write_vectored( self: Pin<&mut Self>, _: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize>>
Attempt to write bytes from
bufs
into the object using vectored
IO operations. Read moreSource§impl<T> BufRead for AllowStdIo<T>where
T: BufRead,
impl<T> BufRead for AllowStdIo<T>where
T: BufRead,
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
from the inner reader if it is empty. Read more
Source§fn consume(&mut self, amt: usize)
fn consume(&mut self, amt: 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 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 the underlying
Read
has any data left to be read. Read more1.83.0 · Source§fn skip_until(&mut self, byte: u8) -> Result<usize, Error>
fn skip_until(&mut self, byte: u8) -> Result<usize, Error>
Skips all bytes until the delimiter
byte
or EOF is reached. Read more1.0.0 · Source§fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>
Reads all bytes until a newline (the
0xA
byte) is reached, and append
them to the provided String
buffer. Read moreSource§impl<T: Clone> Clone for AllowStdIo<T>
impl<T: Clone> Clone for AllowStdIo<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: Debug> Debug for AllowStdIo<T>
impl<T: Debug> Debug for AllowStdIo<T>
Source§impl<T: Hash> Hash for AllowStdIo<T>
impl<T: Hash> Hash for AllowStdIo<T>
Source§impl<T: Ord> Ord for AllowStdIo<T>
impl<T: Ord> Ord for AllowStdIo<T>
Source§fn cmp(&self, other: &AllowStdIo<T>) -> Ordering
fn cmp(&self, other: &AllowStdIo<T>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialEq> PartialEq for AllowStdIo<T>
impl<T: PartialEq> PartialEq for AllowStdIo<T>
Source§impl<T: PartialOrd> PartialOrd for AllowStdIo<T>
impl<T: PartialOrd> PartialOrd for AllowStdIo<T>
Source§impl<T> Read for AllowStdIo<T>where
T: Read,
impl<T> Read for AllowStdIo<T>where
T: Read,
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” adaptor for this instance of
Read
. Read moreSource§impl<T> Seek for AllowStdIo<T>where
T: Seek,
impl<T> Seek for AllowStdIo<T>where
T: Seek,
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
1.55.0 · Source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Rewind to the beginning of a stream. Read more
Source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
🔬This is a nightly-only experimental API. (
seek_stream_len
)Returns the length of this stream (in bytes). Read more
Source§impl<T> Write for AllowStdIo<T>where
T: Write,
impl<T> Write for AllowStdIo<T>where
T: Write,
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, fmt: Arguments<'_>) -> Result<()>
fn write_fmt(&mut self, fmt: 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<T: Copy> Copy for AllowStdIo<T>
impl<T: Eq> Eq for AllowStdIo<T>
impl<T> StructuralPartialEq for AllowStdIo<T>
impl<T> Unpin for AllowStdIo<T>
Auto Trait Implementations§
impl<T> Freeze for AllowStdIo<T>where
T: Freeze,
impl<T> RefUnwindSafe for AllowStdIo<T>where
T: RefUnwindSafe,
impl<T> Send for AllowStdIo<T>where
T: Send,
impl<T> Sync for AllowStdIo<T>where
T: Sync,
impl<T> UnwindSafe for AllowStdIo<T>where
T: 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,
Available on crate feature
io
only.Creates a future which will wait for a non-empty buffer to be available from this I/O
object or EOF to be reached. Read more
Source§fn consume_unpin(&mut self, amt: usize)where
Self: Unpin,
fn consume_unpin(&mut self, amt: usize)where
Self: Unpin,
Available on crate feature
io
only.Source§fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8>,
) -> ReadUntil<'a, Self> ⓘwhere
Self: Unpin,
fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8>,
) -> ReadUntil<'a, Self> ⓘwhere
Self: Unpin,
Available on crate feature
io
only.Creates a future which will read all the bytes associated with this I/O
object into
buf
until the delimiter byte
or EOF is reached.
This method is the async equivalent to BufRead::read_until
. Read moreSource§fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLine<'a, Self> ⓘwhere
Self: Unpin,
fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLine<'a, Self> ⓘwhere
Self: Unpin,
Available on crate feature
io
only.Creates a future which will read all the bytes associated with this I/O
object into
buf
until a newline (the 0xA byte) or EOF is reached,
This method is the async equivalent to BufRead::read_line
. Read moreSource§impl<R> AsyncReadExt for R
impl<R> AsyncReadExt for R
Source§fn chain<R>(self, next: R) -> Chain<Self, R>
fn chain<R>(self, next: R) -> Chain<Self, R>
Available on crate feature
io
only.Creates an adaptor which will chain this stream with another. Read more
Source§fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> ⓘwhere
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> ⓘwhere
Self: Unpin,
Available on crate feature
io
only.Tries to read some bytes directly into the given
buf
in asynchronous
manner, returning a future type. Read moreSource§fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectored<'a, Self> ⓘwhere
Self: Unpin,
fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectored<'a, Self> ⓘwhere
Self: Unpin,
Available on crate feature
io
only.Creates a future which will read from the
AsyncRead
into bufs
using vectored
IO operations. Read moreSource§fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> ⓘwhere
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> ⓘwhere
Self: Unpin,
Available on crate feature
io
only.Creates a future which will read exactly enough bytes to fill
buf
,
returning an error if end of file (EOF) is hit sooner. Read moreSource§fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self> ⓘwhere
Self: Unpin,
fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self> ⓘwhere
Self: Unpin,
Available on crate feature
io
only.Creates a future which will read all the bytes from this
AsyncRead
. Read moreSource§fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToString<'a, Self> ⓘwhere
Self: Unpin,
fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToString<'a, Self> ⓘwhere
Self: Unpin,
Available on crate feature
io
only.Creates a future which will read all the bytes from this
AsyncRead
. 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 flush(&mut self) -> Flush<'_, Self> ⓘwhere
Self: Unpin,
fn flush(&mut self) -> Flush<'_, Self> ⓘwhere
Self: Unpin,
Available on crate feature
io
only.Creates a future which will entirely flush this
AsyncWrite
. Read moreSource§fn close(&mut self) -> Close<'_, Self> ⓘwhere
Self: Unpin,
fn close(&mut self) -> Close<'_, Self> ⓘwhere
Self: Unpin,
Available on crate feature
io
only.Creates a future which will entirely close this
AsyncWrite
.Source§fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self> ⓘwhere
Self: Unpin,
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self> ⓘwhere
Self: Unpin,
Available on crate feature
io
only.Creates a future which will write bytes from
buf
into the object. Read moreSource§fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectored<'a, Self> ⓘwhere
Self: Unpin,
fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectored<'a, Self> ⓘwhere
Self: Unpin,
Available on crate feature
io
only.Creates a future which will write bytes from
bufs
into the object using vectored
IO operations. 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,
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.