Struct async_speed_limit::limiter::Resource[][src]

pub struct Resource<R, 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.

Implementations

impl<R, C: Clock> Resource<R, 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, C>[src]

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

impl<'__pin, R, C: Clock> Unpin for Resource<R, C> where
    __Origin<'__pin, R, C>: Unpin
[src]

Auto Trait Implementations

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

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

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

impl<R, C> UnwindSafe for Resource<R, C> where
    C: UnwindSafe,
    R: 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.