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> 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>>
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>>
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>
Source§fn consume(&mut self, amt: usize)
fn consume(&mut self, amt: usize)
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>
buf_read_has_data_left
)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>
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>
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,
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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,
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>
Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read
, except that it reads into a slice of buffers. Read moreSource§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>
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>
buf
. Read moreSource§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf
. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)Source§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)cursor
. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
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>
1.55.0 · Source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
seek_stream_len
)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>
Source§fn flush(&mut self) -> Result<(), Error>
fn flush(&mut self) -> Result<(), Error>
Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>
fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
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>
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,
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>,
) -> 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,
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,
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>
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,
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,
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,
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,
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,
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,
AsyncWrite
. Read moreSource§fn close(&mut self) -> Close<'_, Self> ⓘwhere
Self: Unpin,
fn close(&mut self) -> Close<'_, Self> ⓘwhere
Self: Unpin,
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,
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,
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
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.