Skip to main content

ServiceExt

Trait ServiceExt 

Source
pub trait ServiceExt<Request>: Service<Request> + Sized {
    // Provided methods
    fn with_timeout(self, timeout: Duration) -> Timeout<Self> { ... }
    fn with_rate_limit(self, max: u64, interval: Duration) -> RateLimit<Self> { ... }
    fn with_concurrency_limit(self, max: usize) -> ConcurrencyLimit<Self> { ... }
    fn map_err<F, E2>(self, f: F) -> MapErr<Self, F>
       where F: FnOnce(Self::Error) -> E2 { ... }
    fn map_response<F, Response2>(self, f: F) -> MapResponse<Self, F>
       where F: FnOnce(Self::Response) -> Response2 { ... }
    fn boxed(self) -> BoxService<Request, Self::Response, Self::Error>
       where Self: Send + 'static,
             Request: Send + 'static,
             Self::Future: Send + 'static { ... }
}
Expand description

Extension trait for ergonomic service composition.

This provides a fluent API for building middleware stacks without manual ServiceBuilder boilerplate.

Provided Methods§

Source

fn with_timeout(self, timeout: Duration) -> Timeout<Self>

Apply a timeout to this service.

Source

fn with_rate_limit(self, max: u64, interval: Duration) -> RateLimit<Self>

Apply rate limiting to this service.

Source

fn with_concurrency_limit(self, max: usize) -> ConcurrencyLimit<Self>

Apply concurrency limiting to this service.

Source

fn map_err<F, E2>(self, f: F) -> MapErr<Self, F>
where F: FnOnce(Self::Error) -> E2,

Map errors from this service.

Source

fn map_response<F, Response2>(self, f: F) -> MapResponse<Self, F>
where F: FnOnce(Self::Response) -> Response2,

Map responses from this service.

Source

fn boxed(self) -> BoxService<Request, Self::Response, Self::Error>
where Self: Send + 'static, Request: Send + 'static, Self::Future: Send + 'static,

Box this service for dynamic dispatch.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T, Request> ServiceExt<Request> for T
where T: Service<Request> + Sized,