Struct grafix_toolbox::uses::asyn::io::BlockOn [−]
pub struct BlockOn<T>(_);
Expand description
Blocks on all async I/O operations and implements std::io traits.
Sometimes async I/O needs to be used in a blocking manner. If calling [future::block_on()]
manually all the time becomes too tedious, use this type for more convenient blocking on async
I/O operations.
This type implements traits Read, Write, or
Seek if the inner type implements AsyncRead, AsyncWrite, or
AsyncSeek, respectively.
If writing data through the Write trait, make sure to flush before
dropping the BlockOn handle or some buffered data might get lost.
Examples
use futures_lite::io::BlockOn; use futures_lite::pin; use std::io::Read; let reader: &[u8] = b"hello"; pin!(reader); let mut blocking_reader = BlockOn::new(reader); let mut contents = String::new(); // This line blocks - note that there is no await: blocking_reader.read_to_string(&mut contents)?;
Implementations
impl<T> BlockOn<T>
impl<T> BlockOn<T>Wraps an async I/O handle into a blocking interface.
Examples
use futures_lite::io::BlockOn; use futures_lite::pin; let reader: &[u8] = b"hello"; pin!(reader); let blocking_reader = BlockOn::new(reader);
Gets a reference to the async I/O handle.
Examples
use futures_lite::io::BlockOn; use futures_lite::pin; let reader: &[u8] = b"hello"; pin!(reader); let blocking_reader = BlockOn::new(reader); let r = blocking_reader.get_ref();
Gets a mutable reference to the async I/O handle.
Examples
use futures_lite::io::BlockOn; use futures_lite::pin; let reader: &[u8] = b"hello"; pin!(reader); let mut blocking_reader = BlockOn::new(reader); let r = blocking_reader.get_mut();
pub fn into_inner(self) -> T
pub fn into_inner(self) -> TExtracts the inner async I/O handle.
Examples
use futures_lite::io::BlockOn; use futures_lite::pin; let reader: &[u8] = b"hello"; pin!(reader); let blocking_reader = BlockOn::new(reader); let inner = blocking_reader.into_inner();
Trait Implementations
impl<T> BufRead for BlockOn<T> where
T: AsyncBufRead + Unpin,
impl<T> BufRead for BlockOn<T> where
T: AsyncBufRead + Unpin, Returns the contents of the internal buffer, filling it with more data from the inner reader if it is empty. Read more
Tells this buffer that amt bytes have been consumed from the buffer,
so they should no longer be returned in calls to read. Read more
🔬 This is a nightly-only experimental API. (buf_read_has_data_left)
recently added
Check if the underlying Read has any data left to be read. Read more
Read all bytes into buf until the delimiter byte or EOF is reached. Read more
Read all bytes until a newline (the 0xA byte) is reached, and append
them to the provided buffer. Read more
Returns an iterator over the contents of this reader split on the byte
byte. Read more
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Like read, except that it reads into a slice of buffers. Read more
can_vector)Determines if this Reader has an efficient read_vectored
implementation. Read more
read_initializer)Determines if this Reader can work with buffers of uninitialized
memory. Read more
Read all bytes until EOF in this source, placing them into buf. Read more
Read all bytes until EOF in this source, appending them to buf. Read more
Read the exact number of bytes required to fill buf. Read more
Creates a “by reference” adaptor for this instance of Read. Read more
Creates an adaptor which will chain this stream with another. Read more
impl<T> Write for BlockOn<T> where
T: AsyncWrite + Unpin,
impl<T> Write for BlockOn<T> where
T: AsyncWrite + Unpin, Write a buffer into this writer, returning how many bytes were written. Read more
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
can_vector)Determines if this Writer has an efficient write_vectored
implementation. Read more
Attempts to write an entire buffer into this writer. Read more
write_all_vectored)Attempts to write multiple buffers into this writer. Read more
Writes a formatted string into this writer, returning any error encountered. Read more
Auto Trait Implementations
impl<T> RefUnwindSafe for BlockOn<T> where
T: RefUnwindSafe, impl<T> UnwindSafe for BlockOn<T> where
T: UnwindSafe, Blanket Implementations
Mutably borrows from an owned value. Read more
Reads an unsigned 8 bit integer from the underlying reader. Read more
Reads a signed 8 bit integer from the underlying reader. Read more
Reads an unsigned 16 bit integer from the underlying reader. Read more
Reads a signed 16 bit integer from the underlying reader. Read more
Reads an unsigned 24 bit integer from the underlying reader. Read more
Reads a signed 24 bit integer from the underlying reader. Read more
Reads an unsigned 32 bit integer from the underlying reader. Read more
Reads a signed 32 bit integer from the underlying reader. Read more
Reads an unsigned 48 bit integer from the underlying reader. Read more
Reads a signed 48 bit integer from the underlying reader. Read more
Reads an unsigned 64 bit integer from the underlying reader. Read more
Reads a signed 64 bit integer from the underlying reader. Read more
Reads an unsigned 128 bit integer from the underlying reader. Read more
Reads a signed 128 bit integer from the underlying reader. Read more
Reads an unsigned n-bytes integer from the underlying reader. Read more
Reads a signed n-bytes integer from the underlying reader. Read more
fn read_uint128<T>(&mut self, nbytes: usize) -> Result<u128, Error> where
T: ByteOrder,
fn read_uint128<T>(&mut self, nbytes: usize) -> Result<u128, Error> where
T: ByteOrder, Reads an unsigned n-bytes integer from the underlying reader.
fn read_int128<T>(&mut self, nbytes: usize) -> Result<i128, Error> where
T: ByteOrder,
fn read_int128<T>(&mut self, nbytes: usize) -> Result<i128, Error> where
T: ByteOrder, Reads a signed n-bytes integer from the underlying reader.
Reads a IEEE754 single-precision (4 bytes) floating point number from the underlying reader. Read more
Reads a IEEE754 double-precision (8 bytes) floating point number from the underlying reader. Read more
Reads a sequence of unsigned 16 bit integers from the underlying reader. Read more
Reads a sequence of unsigned 32 bit integers from the underlying reader. Read more
Reads a sequence of unsigned 64 bit integers from the underlying reader. Read more
Reads a sequence of unsigned 128 bit integers from the underlying reader. Read more
Reads a sequence of signed 8 bit integers from the underlying reader. Read more
Reads a sequence of signed 16 bit integers from the underlying reader. Read more
Reads a sequence of signed 32 bit integers from the underlying reader. Read more
Reads a sequence of signed 64 bit integers from the underlying reader. Read more
Reads a sequence of signed 128 bit integers from the underlying reader. Read more
Reads a sequence of IEEE754 single-precision (4 bytes) floating point numbers from the underlying reader. Read more
Reads a sequence of IEEE754 double-precision (8 bytes) floating point numbers from the underlying reader. Read more
type Output = T
type Output = TShould always be Self
The inverse inclusion map: attempts to construct self from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> boolChecks if self is actually part of its subset T (and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SSUse with care! Same as self.to_subset but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SPThe inclusion map: converts self to the equivalent element of its superset.
pub fn vzip(self) -> VWrites an unsigned 8 bit integer to the underlying writer. Read more
Writes a signed 8 bit integer to the underlying writer. Read more
Writes an unsigned 16 bit integer to the underlying writer. Read more
Writes a signed 16 bit integer to the underlying writer. Read more
Writes an unsigned 24 bit integer to the underlying writer. Read more
Writes a signed 24 bit integer to the underlying writer. Read more
Writes an unsigned 32 bit integer to the underlying writer. Read more
Writes a signed 32 bit integer to the underlying writer. Read more
Writes an unsigned 48 bit integer to the underlying writer. Read more
Writes a signed 48 bit integer to the underlying writer. Read more
Writes an unsigned 64 bit integer to the underlying writer. Read more
Writes a signed 64 bit integer to the underlying writer. Read more
fn write_u128<T>(&mut self, n: u128) -> Result<(), Error> where
T: ByteOrder,
fn write_u128<T>(&mut self, n: u128) -> Result<(), Error> where
T: ByteOrder, Writes an unsigned 128 bit integer to the underlying writer.
fn write_i128<T>(&mut self, n: i128) -> Result<(), Error> where
T: ByteOrder,
fn write_i128<T>(&mut self, n: i128) -> Result<(), Error> where
T: ByteOrder, Writes a signed 128 bit integer to the underlying writer.
Writes an unsigned n-bytes integer to the underlying writer. Read more
Writes a signed n-bytes integer to the underlying writer. Read more
Writes an unsigned n-bytes integer to the underlying writer. Read more
Writes a signed n-bytes integer to the underlying writer. Read more
Writes a IEEE754 single-precision (4 bytes) floating point number to the underlying writer. Read more