[][src]Struct smol::io::Take

pub struct Take<R> { /* fields omitted */ }

Reader for the AsyncReadExt::take() method.

Implementations

impl<R> Take<R>[src]

pub fn limit(&self) -> u64[src]

Returns the number of bytes before this adapter will return EOF.

Note that EOF may be reached sooner if the underlying reader is shorter than the limit.

Examples

use futures_lite::io::{AsyncReadExt, Cursor};

let reader = Cursor::new("hello");

let reader = reader.take(3);
assert_eq!(reader.limit(), 3);

pub fn set_limit(&mut self, limit: u64)[src]

Puts a limit on the number of bytes.

Changing the limit is equivalent to creating a new adapter with AsyncReadExt::take().

Examples

use futures_lite::io::{AsyncReadExt, Cursor};

let reader = Cursor::new("hello");

let mut reader = reader.take(10);
assert_eq!(reader.limit(), 10);

reader.set_limit(3);
assert_eq!(reader.limit(), 3);

pub fn get_ref(&self) -> &R

Notable traits for &'_ mut F

impl<'_, F> Future for &'_ mut F where
    F: Unpin + Future + ?Sized
type Output = <F as Future>::Output;
[src]

Gets a reference to the underlying reader.

Examples

use futures_lite::io::{AsyncReadExt, Cursor};

let reader = Cursor::new("hello");

let reader = reader.take(3);
let r = reader.get_ref();

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

Notable traits for &'_ mut F

impl<'_, F> Future for &'_ mut F where
    F: Unpin + Future + ?Sized
type Output = <F as Future>::Output;
[src]

Gets a mutable reference to the underlying reader.

Examples

use futures_lite::io::{AsyncReadExt, Cursor};

let reader = Cursor::new("hello");

let mut reader = reader.take(3);
let r = reader.get_mut();

pub fn into_inner(self) -> R[src]

Unwraps the adapter, returning the underlying reader.

Examples

use futures_lite::io::{AsyncReadExt, Cursor};

let reader = Cursor::new("hello");

let reader = reader.take(3);
let reader = reader.into_inner();

Trait Implementations

impl<R> AsyncBufRead for Take<R> where
    R: AsyncBufRead
[src]

impl<R> AsyncRead for Take<R> where
    R: AsyncRead
[src]

impl<R> Debug for Take<R> where
    R: Debug
[src]

impl<'__pin, R> Unpin for Take<R> where
    __Origin<'__pin, R>: Unpin
[src]

Auto Trait Implementations

impl<R> RefUnwindSafe for Take<R> where
    R: RefUnwindSafe

impl<R> Send for Take<R> where
    R: Send

impl<R> Sync for Take<R> where
    R: Sync

impl<R> UnwindSafe for Take<R> where
    R: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<R> AsyncBufReadExt for R where
    R: AsyncBufRead + ?Sized
[src]

impl<R> AsyncReadExt for R where
    R: AsyncRead + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.