[][src]Struct casbin::Enforcer

pub struct Enforcer { /* fields omitted */ }

Enforcer is the main interface for authorization enforcement and policy management.

Trait Implementations

impl CoreApi for Enforcer[src]

fn enforce<'life0, 'life1, 'async_trait, S: AsRef<str> + Send + Sync>(
    &'life0 mut self,
    rvals: &'life1 [S]
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where
    S: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Enforce decides whether a "subject" can access a "object" with the operation "action", input parameters are usually: (sub, obj, act).

Examples

use casbin::prelude::*;
#[cfg(feature = "runtime-async-std")]
#[async_std::main]
async fn main() {
    let mut e = Enforcer::new("examples/basic_model.conf", "examples/basic_policy.csv").await.unwrap();
    assert_eq!(true, e.enforce(&["alice", "data1", "read"]).await.unwrap());
}

#[cfg(feature = "runtime-tokio")]
#[tokio::main]
async fn main() {
    let mut e = Enforcer::new("examples/basic_model.conf", "examples/basic_policy.csv").await.unwrap();
    assert_eq!(true, e.enforce(&["alice", "data1", "read"]).await.unwrap());
}
#[cfg(all(not(feature = "runtime-async-std"), not(feature = "runtime-tokio")))]
fn main() {}

impl InternalApi for Enforcer[src]

Auto Trait Implementations

impl !RefUnwindSafe for Enforcer

impl Send for Enforcer

impl Sync for Enforcer

impl Unpin for Enforcer

impl !UnwindSafe for Enforcer

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.