[][src]Struct casbin::Enforcer

pub struct Enforcer { /* fields omitted */ }

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

Methods

impl Enforcer[src]

pub fn new(m: Model, a: Box<dyn Adapter>) -> Result<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 get_model(&self) -> &Model[src]

pub fn get_mut_model(&mut self) -> &mut Model[src]

pub fn set_watcher(&mut self, w: Box<dyn Watcher>)[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, Box::new( adapter)).unwrap();
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 InternalApi for Enforcer[src]

impl MgmtApi for Enforcer[src]

impl RbacApi 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.