Module layer

Expand description

Layer type and utilities.

Layers are the abstraction of middleware in Rama.

Direct copy of tower-layer.

Modules§

add_extension
Middleware that clones a value into the incoming Context.
get_extension
Middleware that gets called with a clone of the value of to given type if it is available in the current Context.
limit
A middleware that limits the number of in-flight requests.
timeout
Middleware that applies a timeout to requests.

Structs§

AddExtension
Middleware for adding some shareable value to incoming Context.
AddExtensionLayer
Layer for adding some shareable value to incoming Context.
ConsumeErr
Consumes this service’s error value and returns Infallible.
ConsumeErrLayer
A Layer that produces ConsumeErr services.
GetExtension
Middleware for adding some shareable value to incoming Context.
GetExtensionLayer
Layer for adding some shareable value to incoming Context.
HijackLayer
Middleware to hijack request to a Service which match using a Matcher.
HijackService
Middleware to hijack request to a Service which match using a Matcher.
LayerErrorFn
A MakeLayerError implementation that returns a new error value every time.
LayerErrorStatic
A MakeLayerError implementation that always returns clone of the same error value.
LayerFn
A Layer implemented by a closure. See the docs for layer_fn for more details.
Limit
Limit requests based on a Policy.
LimitLayer
Limit requests based on a Policy.
MapErr
Maps this service’s error value to a different value.
MapErrLayer
A Layer that produces MapErr services.
MapRequest
Composes a function in front of the service.
MapRequestLayer
A Layer that produces MapRequest services.
MapResponse
Maps this service’s response value to a different value.
MapResponseLayer
A Layer that produces a MapResponse service.
MapResult
Maps this service’s result type (Result<Self::Response, Self::Error>) to a different value, regardless of whether the future succeeds or fails.
MapResultLayer
A Layer that produces a MapResult service.
MapState
Middleware that can be used to map the state, and pass it as the new state for the inner service.
MapStateLayer
Middleware that can be used to map the state, and pass it as the new state for the inner service.
Timeout
Applies a timeout to requests.
TimeoutLayer
Applies a timeout to requests via the supplied inner service.
TraceErr
Service which traces the error using [tracing], of the inner Service.
TraceErrLayer
A Layer that produces TraceErr services.

Traits§

Layer
A layer that produces a Layered service (middleware(inner service)).
MakeLayerError
Utility error trait to allow Rama layers to return a default error as well as a user-defined one, being it a Clone-able type or a Fn returning an error type.

Functions§

layer_fn
Returns a new LayerFn that implements Layer by calling the given function.