[]Struct async_speed_limit::limiter::Resource

pub struct Resource<R, T, C: Clock> { /* fields omitted */ }

A speed-limited wrapper of a byte stream.

The Resource can be used to limit speed of

Just like Limiter, the delay is inserted after the data are sent or received, in which we know the exact amount of bytes transferred to give an accurate delay. The instantaneous speed can exceed the limit if many read/write tasks are started simultaneously. Therefore, restricting the concurrency is also important to avoid breaching the constraint.

Methods

impl<R, T, C: Clock> Resource<R, T, C>[src]

pub fn new(limiter: Limiter<C>, resource: R) -> Self[src]

Creates a new speed-limited resource.

To make the resouce have unlimited speed, set the speed of Limiter to infinity.

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

Unwraps this value, returns the underlying resource.

pub fn get_ref(&self) -> &R[src]

Gets a reference to the underlying resource.

It is inadvisable to directly operate the underlying resource.

pub fn get_mut(&mut self) -> &mut R[src]

Gets a mutable reference to the underlying resource.

It is inadvisable to directly operate the underlying resource.

pub fn get_pin_ref(self: Pin<&Self>) -> Pin<&R>[src]

Gets a pinned reference to the underlying resource.

It is inadvisable to directly operate the underlying resource.

pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut R>[src]

Gets a pinned mutable reference to the underlying resource.

It is inadvisable to directly operate the underlying resource.

Trait Implementations

impl<R: AsyncRead, C: Clock> AsyncRead for Resource<R, Result<usize>, C>[src]

impl<R: AsyncWrite, C: Clock> AsyncWrite for Resource<R, Result<usize>, C>[src]

impl<'__pin, R, T, C: Clock> Unpin for Resource<R, T, C> where
    __Origin<'__pin, R, T, C>: Unpin

Auto Trait Implementations

impl<R, T, C> RefUnwindSafe for Resource<R, T, C> where
    C: RefUnwindSafe,
    R: RefUnwindSafe,
    T: RefUnwindSafe,
    <C as Clock>::Delay: RefUnwindSafe

impl<R, T, C> Send for Resource<R, T, C> where
    C: Send,
    R: Send,
    T: Send,
    <C as Clock>::Delay: Send,
    <C as Clock>::Instant: Send

impl<R, T, C> Sync for Resource<R, T, C> where
    C: Sync,
    R: Sync,
    T: Sync,
    <C as Clock>::Delay: Sync,
    <C as Clock>::Instant: Send

impl<R, T, C> UnwindSafe for Resource<R, T, C> where
    C: UnwindSafe,
    R: UnwindSafe,
    T: UnwindSafe,
    <C as Clock>::Delay: UnwindSafe

Blanket Implementations

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