Struct async_speed_limit::limiter::Resource [−][src]
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]
fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8]
) -> Poll<Result<usize>>
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8]
) -> Poll<Result<usize>>
fn poll_read_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &mut [IoSliceMut<'_>]
) -> Poll<Result<usize>>
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &mut [IoSliceMut<'_>]
) -> Poll<Result<usize>>
impl<R: AsyncWrite, C: Clock> AsyncWrite for Resource<R, C>
[src]
fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize>>
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize>>
fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>]
) -> Poll<Result<usize>>
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>]
) -> Poll<Result<usize>>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
[src]
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
[src]
impl<'__pin, R, C: Clock> Unpin for Resource<R, C> where
__Origin<'__pin, R, C>: Unpin,
[src]
__Origin<'__pin, R, C>: Unpin,
Auto Trait Implementations
impl<R, C> RefUnwindSafe for Resource<R, C> where
C: RefUnwindSafe,
R: RefUnwindSafe,
<C as Clock>::Delay: RefUnwindSafe,
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,
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,
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,
C: UnwindSafe,
R: UnwindSafe,
<C as Clock>::Delay: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,