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) -> Self

Creates a new BufferLayer with the provided bound.

bound gives the maximal number of requests that can be queued for the service before backpressure is applied to callers.

A note on choosing a bound

When Buffer's implementation of poll_ready returns Poll::Ready, it reserves a slot in the channel for the forthcoming call. 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 set bound to be at least the maximum number of concurrent requests the Buffer will see. If you do not, all the slots in the buffer may be held up by futures that have just called poll_ready but will not issue a call, 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) -> T

Returns 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) -> T
fn 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) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses 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>