[][src]Struct casbin::Enforcer

pub struct Enforcer<A: Adapter> { /* fields omitted */ }

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

Methods

impl<A: Adapter> Enforcer<A>[src]

pub fn new(m: Model, a: A) -> Self[src]

Enforcer::new creates an enforcer via file or DB.

pub fn add_function(&mut self, fname: &str, f: fn(_: String, _: String) -> bool)[src]

pub fn enforce(&self, rvals: Vec<&str>) -> Result<bool>[src]

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

Examples

use casbin::{Enforcer, Model, FileAdapter};

let m = Model::from_file("examples/basic_model.conf").unwrap();
let adapter = FileAdapter::new("examples/basic_policy.csv");
let e = Enforcer::new(m, adapter);
assert_eq!(true, e.enforce(vec!["alice", "data1", "read"]).unwrap());

pub fn load_policy(&mut self) -> Result<()>[src]

pub fn clear_policy(&mut self)[src]

pub fn enable_auto_save(&mut self, auto_save: bool)[src]

Trait Implementations

impl<A: Adapter> InternalApi for Enforcer<A>[src]

impl<A: Adapter> MgmtApi for Enforcer<A>[src]

impl<A: Adapter> RbacApi for Enforcer<A>[src]

Auto Trait Implementations

impl<A> !RefUnwindSafe for Enforcer<A>

impl<A> Send for Enforcer<A> where
    A: Send

impl<A> Sync for Enforcer<A> where
    A: Sync

impl<A> Unpin for Enforcer<A> where
    A: Unpin

impl<A> !UnwindSafe for Enforcer<A>

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.