futures::io

Struct AllowStdIo

Source
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>

Source

pub fn new(io: T) -> AllowStdIo<T>

Creates a new AllowStdIo from an existing IO object.

Source

pub fn get_ref(&self) -> &T

Returns a reference to the contained IO object.

Source

pub fn get_mut(&mut self) -> &mut T

Returns a mutable reference to the contained IO object.

Source

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,

Source§

fn poll_read( &mut self, _: &mut Context<'_>, buf: &mut [u8], ) -> Result<Async<usize>, Error>

Attempt to read from the AsyncRead into buf. Read more
Source§

unsafe fn initializer(&self) -> Initializer

Determines if this AsyncReader can work with buffers of uninitialized memory. Read more
Source§

fn poll_vectored_read( &mut self, cx: &mut Context<'_>, vec: &mut [&mut IoVec], ) -> Result<Async<usize>, Error>

Attempt to read from the AsyncRead into vec using vectored IO operations. Read more
Source§

impl<T> AsyncWrite for AllowStdIo<T>
where T: Write,

Source§

fn poll_write( &mut self, _: &mut Context<'_>, buf: &[u8], ) -> Result<Async<usize>, Error>

Attempt to write bytes from buf into the object. Read more
Source§

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§

fn poll_close(&mut self, cx: &mut Context<'_>) -> Result<Async<()>, Error>

Attempt to close the object. Read more
Source§

fn poll_vectored_write( &mut self, cx: &mut Context<'_>, vec: &[&IoVec], ) -> Result<Async<usize>, Error>

Attempt to write bytes from vec into the object using vectored IO operations. Read more
Source§

impl<T> Clone for AllowStdIo<T>
where T: Clone,

Source§

fn clone(&self) -> AllowStdIo<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for AllowStdIo<T>
where T: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T> Hash for AllowStdIo<T>
where T: Hash,

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> Ord for AllowStdIo<T>
where T: Ord,

Source§

fn cmp(&self, other: &AllowStdIo<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T> PartialEq for AllowStdIo<T>
where T: PartialEq,

Source§

fn eq(&self, other: &AllowStdIo<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> PartialOrd for AllowStdIo<T>
where T: PartialOrd,

Source§

fn partial_cmp(&self, other: &AllowStdIo<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T> Read for AllowStdIo<T>
where T: Read,

Source§

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>

Reads all bytes until EOF in this source, placing them into buf. Read more
Source§

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 more
Source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>

Reads the exact number of bytes required to fill buf. Read more
1.36.0 · Source§

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>

Like read, except that it reads into a slice of buffers. Read more
Source§

fn is_read_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
Source§

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>

🔬This is a nightly-only experimental API. (read_buf)
Reads the exact number of bytes required to fill cursor. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adaptor for this instance of Read. Read more
1.0.0 · Source§

fn bytes(self) -> Bytes<Self>
where Self: Sized,

Transforms this Read instance to an Iterator over its bytes. Read more
1.0.0 · Source§

fn chain<R>(self, next: R) -> Chain<Self, R>
where R: Read, Self: Sized,

Creates an adapter which will chain this stream with another. Read more
1.0.0 · Source§

fn take(self, limit: u64) -> Take<Self>
where Self: Sized,

Creates an adapter which will read at most limit bytes from it. Read more
Source§

impl<T> Write for AllowStdIo<T>
where T: Write,

Source§

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>

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>

Attempts to write an entire buffer into this writer. Read more
Source§

fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.36.0 · Source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

Like write, except that it writes from a slice of buffers. Read more
Source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
Source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more
Source§

impl<T> Copy for AllowStdIo<T>
where T: Copy,

Source§

impl<T> Eq for AllowStdIo<T>
where T: Eq,

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsyncReadExt for T
where T: AsyncRead + ?Sized,

Source§

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>
where T: AsMut<[u8]>, Self: Sized,

Tries to read some bytes directly into the given buf in asynchronous manner, returning a future type. Read more
Source§

fn read_exact<T>(self, buf: T) -> ReadExact<Self, T>
where T: AsMut<[u8]>, Self: Sized,

Creates a future which will read exactly enough bytes to fill buf, returning an error if EOF is hit sooner. Read more
Source§

fn read_to_end(self, buf: Vec<u8>) -> ReadToEnd<Self>
where Self: Sized,

Creates a future which will read all the bytes from this AsyncRead. Read more
Source§

fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>)
where Self: Sized + AsyncWrite,

Helper method for splitting this read/write object into two halves. Read more
Source§

impl<T> AsyncWriteExt for T
where T: AsyncWrite + ?Sized,

Source§

fn flush(self) -> Flush<Self>
where Self: Sized,

Creates a future which will entirely flush this AsyncWrite and then return self. Read more
Source§

fn close(self) -> Close<Self>
where Self: Sized,

Creates a future which will entirely close this AsyncWrite and then return self. Read more
Source§

fn write_all<T>(self, buf: T) -> WriteAll<Self, T>
where T: AsRef<[u8]>, Self: Sized,

Write a Buf into this value, returning how many bytes were written. Creates a future that will write the entire contents of the buffer buf into this AsyncWrite. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.