pub fn from_fn<P, F>(decide: F) -> FromFn<F>Expand description
Returns a policy that decides with the synchronous closure decide.
ยงExamples
use moq_ext_access::{
Grant,
policy::{self, PeerRequest, Rejection},
};
let policy = policy::from_fn(|request: &PeerRequest<String>| {
if request.token() == Some("secret") {
Ok(Grant::everything().into())
} else {
Err(Rejection::new("no valid token"))
}
});