Struct futures::io::AllowStdIo
source · pub struct AllowStdIo<T>(_);
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 new(io: T) -> AllowStdIo<T> ⓘ
pub fn new(io: T) -> AllowStdIo<T> ⓘ
Creates a new AllowStdIo
from an existing IO object.
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 AllowStdIo<T>>,
_: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize, Error>>
fn poll_write( self: Pin<&mut AllowStdIo<T>>, _: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize, Error>>
Attempt to write bytes from
buf
into the object. Read moresource§fn poll_write_vectored(
self: Pin<&mut AllowStdIo<T>>,
_: &mut Context<'_>,
bufs: &[IoSlice<'_>]
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut AllowStdIo<T>>, _: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
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], Error>
fn fill_buf(&mut self) -> Result<&[u8], Error>
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
)Check if the underlying
Read
has any data left to be read. Read more1.0.0 · source§fn read_until(
&mut self,
byte: u8,
buf: &mut Vec<u8, Global>
) -> Result<usize, Error>
fn read_until( &mut self, byte: u8, buf: &mut Vec<u8, Global> ) -> Result<usize, Error>
1.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>
Read all bytes until a newline (the
0xA
byte) is reached, and append
them to the provided String
buffer. Read moresource§impl<T> Clone for AllowStdIo<T>where
T: Clone,
impl<T> Clone for AllowStdIo<T>where T: Clone,
source§impl<T> Debug for AllowStdIo<T>where
T: Debug,
impl<T> Debug for AllowStdIo<T>where T: Debug,
source§impl<T> Hash for AllowStdIo<T>where
T: Hash,
impl<T> Hash for AllowStdIo<T>where T: Hash,
source§impl<T> Ord for AllowStdIo<T>where
T: Ord,
impl<T> Ord for AllowStdIo<T>where T: Ord,
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<AllowStdIo<T>> for AllowStdIo<T>where
T: PartialEq<T>,
impl<T> PartialEq<AllowStdIo<T>> for AllowStdIo<T>where T: PartialEq<T>,
source§fn eq(&self, other: &AllowStdIo<T>) -> bool
fn eq(&self, other: &AllowStdIo<T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<T> PartialOrd<AllowStdIo<T>> for AllowStdIo<T>where
T: PartialOrd<T>,
impl<T> PartialOrd<AllowStdIo<T>> for AllowStdIo<T>where T: PartialOrd<T>,
source§fn partial_cmp(&self, other: &AllowStdIo<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &AllowStdIo<T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§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, Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
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, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
Like
read
, except that it reads into a slice of buffers. Read moresource§fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
Read all bytes until EOF in this source, placing them into
buf
. Read moresource§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
Read all bytes until EOF in this source, appending them to
buf
. Read moresource§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
Read 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
)Read 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, Error>
fn seek(&mut self, pos: SeekFrom) -> Result<u64, Error>
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§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, Error>
fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
Write a buffer into this writer, returning how many bytes were written. Read more
source§fn flush(&mut self) -> Result<(), Error>
fn flush(&mut self) -> Result<(), Error>
Flush this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
source§fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>
fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>
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 for AllowStdIo<T>where T: Copy,
impl<T> Eq for AllowStdIo<T>where T: Eq,
impl<T> StructuralEq for AllowStdIo<T>
impl<T> StructuralPartialEq for AllowStdIo<T>
impl<T> Unpin for AllowStdIo<T>
Auto Trait Implementations§
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,
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,
source§fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8, Global>
) -> ReadUntil<'a, Self> ⓘwhere
Self: Unpin,
fn read_until<'a>( &'a mut self, byte: u8, buf: &'a mut Vec<u8, Global> ) -> ReadUntil<'a, Self> ⓘwhere Self: Unpin,
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,
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 Rwhere
R: AsyncRead + ?Sized,
impl<R> AsyncReadExt for Rwhere R: AsyncRead + ?Sized,
source§fn chain<R>(self, next: R) -> Chain<Self, R>where
Self: Sized,
R: AsyncRead,
fn chain<R>(self, next: R) -> Chain<Self, R>where Self: Sized, R: AsyncRead,
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,
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,
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,
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, Global>
) -> ReadToEnd<'a, Self> ⓘwhere
Self: Unpin,
fn read_to_end<'a>( &'a mut self, buf: &'a mut Vec<u8, Global> ) -> ReadToEnd<'a, Self> ⓘwhere Self: Unpin,
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,
Creates a future which will read all the bytes from this
AsyncRead
. Read moresource§impl<S> AsyncSeekExt for Swhere
S: AsyncSeek + ?Sized,
impl<S> AsyncSeekExt for Swhere S: AsyncSeek + ?Sized,
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,
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,
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,
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,
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