Skip to main content

Policy

Trait Policy 

Source
pub trait Policy<M>:
    Send
    + Sync
    + 'static {
    // Required method
    fn allows(&self, cx: &Cx, ability: Ability<'_, M>) -> bool;
}
Expand description

Decides which Abilitys the current user has over a resource’s records.

A closure |cx: &Cx, ability: Ability<'_, M>| -> bool is a policy, and the building blocks combine with and and or.

Required Methods§

Source

fn allows(&self, cx: &Cx, ability: Ability<'_, M>) -> bool

Whether the current user may do ability.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<M, A: Policy<M>, B: Policy<M>> Policy<M> for And<A, B>

Source§

impl<M, A: Policy<M>, B: Policy<M>> Policy<M> for Or<A, B>

Source§

impl<M, F> Policy<M> for F
where F: Fn(&Cx, Ability<'_, M>) -> bool + Send + Sync + 'static,

Source§

impl<M, F> Policy<M> for When<F>
where F: Fn(&Cx) -> bool + Send + Sync + 'static,

Source§

impl<M> Policy<M> for Allow

Source§

impl<M> Policy<M> for Deny

Source§

impl<M> Policy<M> for ReadOnly