pub trait Policy<State, Request>: Send + Sync + 'static {
type Guard: Send + 'static;
type Error: Send + Sync + 'static;
// Required method
fn check(
&self,
ctx: Context<State>,
request: Request,
) -> impl Future<Output = PolicyResult<State, Request, Self::Guard, Self::Error>> + Send;
}
Expand description
A limit Policy
is used to determine whether a request is allowed to proceed,
and if not, how to handle it.
Required Associated Types§
type Guard: Send + 'static
type Guard: Send + 'static
The guard type that is returned when the request is allowed to proceed.
See PolicyOutput::Ready
.
type Error: Send + Sync + 'static
type Error: Send + Sync + 'static
The error type that is returned when the request is not allowed to proceed, and should be aborted.
See PolicyOutput::Abort
.
Required Methods§
fn check(
&self,
ctx: Context<State>,
request: Request,
) -> impl Future<Output = PolicyResult<State, Request, Self::Guard, Self::Error>> + Send
fn check( &self, ctx: Context<State>, request: Request, ) -> impl Future<Output = PolicyResult<State, Request, Self::Guard, Self::Error>> + Send
Check whether the request is allowed to proceed.
Optionally modify the request before it is passed to the inner service, which can be used to add metadata to the request regarding how the request was handled by this limit policy.
Object Safety§
This trait is not object safe.