Struct BufferLayer
pub struct BufferLayer<Request> { /* private fields */ }
Adds an mpsc buffer in front of an inner service.
The default Tokio executor is used to run the given service, which means that this layer can only be used on the Tokio runtime.
See the module documentation for more details.
Implementations
impl<Request> BufferLayer<Request>
const fn new(bound: usize) -> SelfCreates a new
BufferLayerwith the providedbound.boundgives the maximal number of requests that can be queued for the service before backpressure is applied to callers.A note on choosing a
boundWhen
Buffer's implementation ofpoll_readyreturnsPoll::Ready, it reserves a slot in the channel for the forthcomingcall. However, if this call doesn't arrive, this reserved slot may be held up for a long time. As a result, it's advisable to setboundto be at least the maximum number of concurrent requests theBufferwill see. If you do not, all the slots in the buffer may be held up by futures that have just calledpoll_readybut will not issue acall, which prevents other senders from issuing new requests.
Trait Implementations
impl<Request> Clone for BufferLayer<Request>
fn clone(&self) -> Self
impl<Request> Copy for BufferLayer<Request>
impl<Request> Debug for BufferLayer<Request>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<S, Request> Layer<S> for BufferLayer<Request>
where
S: Service<Request> + Send + 'static,
S::Future: Send,
S::Error: Into<BoxError> + Send + Sync,
Request: Send + 'static,
type Service = Buffer<Request, <S as Service<Request>>::Future>;fn layer(&self, service: S) -> Self::Service
Auto Trait Implementations
impl<Request> Freeze for BufferLayer<Request>
where
PhantomData<fn(Request)>: Freeze,
impl<Request> RefUnwindSafe for BufferLayer<Request>
where
PhantomData<fn(Request)>: RefUnwindSafe,
impl<Request> Send for BufferLayer<Request>
where
PhantomData<fn(Request)>: Send,
impl<Request> Sync for BufferLayer<Request>
where
PhantomData<fn(Request)>: Sync,
impl<Request> Unpin for BufferLayer<Request>
where
PhantomData<fn(Request)>: Unpin,
impl<Request> UnsafeUnpin for BufferLayer<Request>
where
PhantomData<fn(Request)>: UnsafeUnpin,
impl<Request> UnwindSafe for BufferLayer<Request>
where
PhantomData<fn(Request)>: UnwindSafe,
Blanket Implementations
impl<T> Any for BufferLayer<Request>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for BufferLayer<Request>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for BufferLayer<Request>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for BufferLayer<Request>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for BufferLayer<Request>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Instrument for BufferLayer<Request>
impl<T> ToOwned for BufferLayer<Request>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T> WithSubscriber for BufferLayer<Request>
impl<T, U> Into<U> for BufferLayer<Request>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for BufferLayer<Request>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for BufferLayer<Request>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>