pub struct AllowStdIo<T>(/* private fields */);
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> AsyncRead for AllowStdIo<T>where
T: Read,
impl<T> AsyncRead for AllowStdIo<T>where
T: Read,
Source§impl<T> AsyncWrite for AllowStdIo<T>where
T: Write,
impl<T> AsyncWrite for AllowStdIo<T>where
T: Write,
Source§fn poll_write(
&mut self,
_: &mut Context<'_>,
buf: &[u8],
) -> Result<Async<usize>, Error>
fn poll_write( &mut self, _: &mut Context<'_>, buf: &[u8], ) -> Result<Async<usize>, Error>
Attempt to write bytes from
buf
into the object. Read moreSource§fn poll_flush(&mut self, _: &mut Context<'_>) -> Result<Async<()>, Error>
fn poll_flush(&mut self, _: &mut Context<'_>) -> Result<Async<()>, Error>
Attempt to flush the object, ensuring that any buffered data reach
their destination. Read more
Source§impl<T> Clone for AllowStdIo<T>where
T: Clone,
impl<T> Clone for AllowStdIo<T>where
T: Clone,
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 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 for AllowStdIo<T>where
T: PartialEq,
impl<T> PartialEq for AllowStdIo<T>where
T: PartialEq,
Source§impl<T> PartialOrd for AllowStdIo<T>where
T: PartialOrd,
impl<T> PartialOrd for AllowStdIo<T>where
T: PartialOrd,
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, 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_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
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, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
Reads 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>
Reads the exact number of bytes required to fill
buf
. Read more1.36.0 · 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 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> 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>
Writes 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>
Flushes 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> StructuralPartialEq 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> Unpin for AllowStdIo<T>where
T: Unpin,
impl<T> UnwindSafe for AllowStdIo<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> AsyncReadExt for T
impl<T> AsyncReadExt for T
Source§fn copy_into<W>(self, writer: W) -> CopyInto<Self, W>where
W: AsyncWrite,
Self: Sized,
fn copy_into<W>(self, writer: W) -> CopyInto<Self, W>where
W: AsyncWrite,
Self: Sized,
Creates a future which copies all the bytes from one object to another. Read more
Source§fn read<T>(self, buf: T) -> Read<Self, T>
fn read<T>(self, buf: T) -> Read<Self, T>
Tries to read some bytes directly into the given
buf
in asynchronous
manner, returning a future type. Read moreSource§fn read_exact<T>(self, buf: T) -> ReadExact<Self, T>
fn read_exact<T>(self, buf: T) -> ReadExact<Self, T>
Creates a future which will read exactly enough bytes to fill
buf
,
returning an error if EOF is hit sooner. Read moreSource§impl<T> AsyncWriteExt for Twhere
T: AsyncWrite + ?Sized,
impl<T> AsyncWriteExt for Twhere
T: AsyncWrite + ?Sized,
Source§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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more