pub struct Buffer<T, Request>where
T: Service<Request>,{ /* private fields */ }
Expand description
Adds a buffer in front of an inner service.
See crate level documentation for more details.
Implementations§
Source§impl<T, Request> Buffer<T, Request>
impl<T, Request> Buffer<T, Request>
Sourcepub fn new(service: T, bound: usize) -> Self
pub fn new(service: T, bound: usize) -> Self
Creates a new Buffer
wrapping service
.
bound
gives the maximal number of requests that can be queued for the service before
backpressure is applied to callers.
The default Tokio executor is used to run the given service, which means that this method must be called while on the Tokio runtime.
Sourcepub fn pair(
service: T,
bound: usize,
) -> (Buffer<T, Request>, Worker<T, Request>)
pub fn pair( service: T, bound: usize, ) -> (Buffer<T, Request>, Worker<T, Request>)
Creates a new Buffer
wrapping service
but returns the background worker.
This is useful if you do not want to spawn directly onto the tokio
runtime
but instead want to use your own executor. This will return the Buffer
and
the background Worker
that you can then spawn.
Trait Implementations§
Auto Trait Implementations§
impl<T, Request> Freeze for Buffer<T, Request>
impl<T, Request> !RefUnwindSafe for Buffer<T, Request>
impl<T, Request> Send for Buffer<T, Request>
impl<T, Request> Sync for Buffer<T, Request>
impl<T, Request> Unpin for Buffer<T, Request>
impl<T, Request> !UnwindSafe for Buffer<T, Request>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)