Skip to main content

AsyncReadBytes

Struct AsyncReadBytes 

Source
pub struct AsyncReadBytes<'a, R>(/* private fields */)
where
    R: AsyncReadExt + Unpin;
Expand description

Wraps a type that implements AsyncReadExt to extend its functionality with methods for reading numbers (for futures_lite::io).

Note: This is a struct wrapper instead of a trait like in the original byteorder crate because it would require for either extremely painful code or to import the heavy proc-macro crate that is async-trait

Implementations§

Source§

impl<'a, R> AsyncReadBytes<'a, R>
where R: AsyncReadExt + Unpin,

Source

pub const fn new(reader: &'a mut R) -> Self

Creates a new AsyncReadBytes wrapper around the given reader.

§Examples
use futures_byteorder::AsyncReadBytes;
use futures_lite::io::Cursor;

let data = vec![0x12, 0x34];
let mut reader = Cursor::new(data);
let reader = AsyncReadBytes::new(&mut reader);
Source

pub async fn read_representable<E, Re>(&mut self) -> Result<Re>
where E: Endianness, Re: Representable,

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_u8(&mut self) -> Result<u8>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_i8(&mut self) -> Result<i8>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source§

impl<R> AsyncReadBytes<'_, R>
where R: AsyncReadExt + Unpin,

Source

pub async fn read_u16<E: Endianness>(&mut self) -> Result<u16>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_u16_ne(&mut self) -> Result<u16>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_u32<E: Endianness>(&mut self) -> Result<u32>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_u32_ne(&mut self) -> Result<u32>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_u64<E: Endianness>(&mut self) -> Result<u64>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_u64_ne(&mut self) -> Result<u64>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_u128<E: Endianness>(&mut self) -> Result<u128>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_u128_ne(&mut self) -> Result<u128>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_i16<E: Endianness>(&mut self) -> Result<i16>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_i16_ne(&mut self) -> Result<i16>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_i32<E: Endianness>(&mut self) -> Result<i32>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_i32_ne(&mut self) -> Result<i32>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_i64<E: Endianness>(&mut self) -> Result<i64>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_i64_ne(&mut self) -> Result<i64>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_i128<E: Endianness>(&mut self) -> Result<i128>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_i128_ne(&mut self) -> Result<i128>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_f32<E: Endianness>(&mut self) -> Result<f32>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_f32_ne(&mut self) -> Result<f32>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_f64<E: Endianness>(&mut self) -> Result<f64>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Source

pub async fn read_f64_ne(&mut self) -> Result<f64>

§Errors

This method returns the same errors as AsyncReadExt::read_exact.

Trait Implementations§

Source§

impl<R> Deref for AsyncReadBytes<'_, R>
where R: AsyncReadExt + Unpin,

Source§

type Target = R

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<R> DerefMut for AsyncReadBytes<'_, R>
where R: AsyncReadExt + Unpin,

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'a, R> From<&'a mut R> for AsyncReadBytes<'a, R>
where R: AsyncReadExt + Unpin,

Source§

fn from(reader: &'a mut R) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a, R> Freeze for AsyncReadBytes<'a, R>

§

impl<'a, R> RefUnwindSafe for AsyncReadBytes<'a, R>
where R: RefUnwindSafe,

§

impl<'a, R> Send for AsyncReadBytes<'a, R>
where R: Send,

§

impl<'a, R> Sync for AsyncReadBytes<'a, R>
where R: Sync,

§

impl<'a, R> Unpin for AsyncReadBytes<'a, R>

§

impl<'a, R> !UnwindSafe for AsyncReadBytes<'a, R>

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> 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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.