Struct tower_memlim::service::MemoryLimit

source ·
pub struct MemoryLimit<T, M>
where M: AvailableMemory,
{ /* private fields */ }
Expand description

Enforces a limit on the underlying service when a memory threshold is met.

Implementations§

source§

impl<T, M> MemoryLimit<T, M>
where M: AvailableMemory,

source

pub fn new(inner: T, threshold: Threshold, mem_checker: M) -> Self

Create a new memory limiter.

source

pub fn get_ref(&self) -> &T

Get a reference to the inner service

source

pub fn get_mut(&mut self) -> &mut T

Get a mutable reference to the inner service

source

pub fn into_inner(self) -> T

Consume self, returning the inner service

Trait Implementations§

source§

impl<T: Debug, M> Debug for MemoryLimit<T, M>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<S, Request, M> Service<Request> for MemoryLimit<S, M>
where S: Service<Request>, M: AvailableMemory, S::Error: Into<BoxError>,

source§

type Response = <S as Service<Request>>::Response

Responses given by the service.
source§

type Error = Box<dyn Error + Send + Sync>

Errors produced by the service.
source§

type Future = ResponseFuture<<S as Service<Request>>::Future>

The future response value.
source§

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>

Returns Poll::Ready(Ok(())) when the service is able to process requests. Read more
source§

fn call(&mut self, request: Request) -> Self::Future

Process the request and return the response asynchronously. Read more

Auto Trait Implementations§

§

impl<T, M> Freeze for MemoryLimit<T, M>
where T: Freeze, M: Freeze,

§

impl<T, M> !RefUnwindSafe for MemoryLimit<T, M>

§

impl<T, M> Send for MemoryLimit<T, M>
where T: Send, M: Send,

§

impl<T, M> Sync for MemoryLimit<T, M>
where T: Sync, M: Sync,

§

impl<T, M> Unpin for MemoryLimit<T, M>
where T: Unpin, M: Unpin,

§

impl<T, M> !UnwindSafe for MemoryLimit<T, M>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.