Trait Policy
pub trait Policy<P>:
Debug
+ Send
+ Sync
+ 'staticwhere
P: PeerId,{
// Required method
fn decide(
&self,
request: &PeerRequest<P>,
) -> impl Future<Output = Result<Authorization, Rejection>> + Send;
// Provided method
fn filter<F>(self, admit: F) -> Filter<Self, F>
where Self: Sized,
F: Fn(&PeerRequest<P>) -> bool + Send + Sync + 'static { ... }
}Expand description
A rule that decides whether a peer may hold a session, and with which rights.
Implement it with async fn decide.
Required Methods§
fn decide(
&self,
request: &PeerRequest<P>,
) -> impl Future<Output = Result<Authorization, Rejection>> + Send
fn decide( &self, request: &PeerRequest<P>, ) -> impl Future<Output = Result<Authorization, Rejection>> + Send
Decides whether the peer may hold a session, and with which rights.
A node drops the future on its decide timeout and when it shuts down, so an implementation must tolerate cancellation at any await.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".