[][src]Trait casbin::prelude::CoreApi

pub trait CoreApi: Send + Sync {
#[must_use]    pub fn new_raw<'async_trait, M: TryIntoModel, A: TryIntoAdapter>(
        m: M,
        a: A
    ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
    where
        Self: Sized,
        M: 'async_trait,
        A: 'async_trait,
        Self: 'async_trait
;
#[must_use] pub fn new<'async_trait, M: TryIntoModel, A: TryIntoAdapter>(
        m: M,
        a: A
    ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
    where
        Self: Sized,
        M: 'async_trait,
        A: 'async_trait,
        Self: 'async_trait
;
pub fn add_function(
        &mut self,
        fname: &str,
        f: fn(_: ImmutableString, _: ImmutableString) -> bool
    );
pub fn get_model(&self) -> &dyn Model;
pub fn get_mut_model(&mut self) -> &mut dyn Model;
pub fn get_adapter(&self) -> &dyn Adapter;
pub fn get_mut_adapter(&mut self) -> &mut dyn Adapter;
pub fn get_role_manager(&self) -> Arc<RwLock<dyn RoleManager>>;
pub fn set_role_manager(
        &mut self,
        rm: Arc<RwLock<dyn RoleManager>>
    ) -> Result<()>;
#[must_use] pub fn set_model<'life0, 'async_trait, M: TryIntoModel>(
        &'life0 mut self,
        m: M
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
    where
        Self: Sized,
        M: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] pub fn set_adapter<'life0, 'async_trait, A: TryIntoAdapter>(
        &'life0 mut self,
        a: A
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
    where
        Self: Sized,
        A: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
;
pub fn set_effector(&mut self, e: Box<dyn Effector>);
pub fn enforce<ARGS: EnforceArgs>(&self, rvals: ARGS) -> Result<bool>
    where
        Self: Sized
;
pub fn enforce_mut<ARGS: EnforceArgs>(
        &mut self,
        rvals: ARGS
    ) -> Result<bool>
    where
        Self: Sized
;
pub fn build_role_links(&mut self) -> Result<()>;
pub fn build_incremental_role_links(&mut self, d: EventData) -> Result<()>;
#[must_use] pub fn load_policy<'life0, 'async_trait>(
        &'life0 mut self
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] pub fn load_filtered_policy<'a, 'life0, 'async_trait>(
        &'life0 mut self,
        f: Filter<'a>
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
    where
        'a: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
;
pub fn is_filtered(&self) -> bool;
pub fn is_enabled(&self) -> bool;
#[must_use] pub fn save_policy<'life0, 'async_trait>(
        &'life0 mut self
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] pub fn clear_policy<'life0, 'async_trait>(
        &'life0 mut self
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
pub fn enable_auto_save(&mut self, auto_save: bool);
pub fn enable_enforce(&mut self, enabled: bool);
pub fn enable_auto_build_role_links(&mut self, auto_build_role_links: bool);
pub fn has_auto_save_enabled(&self) -> bool;
pub fn has_auto_build_role_links_enabled(&self) -> bool; }

Required methods

#[must_use]pub fn new_raw<'async_trait, M: TryIntoModel, A: TryIntoAdapter>(
    m: M,
    a: A
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>> where
    Self: Sized,
    M: 'async_trait,
    A: 'async_trait,
    Self: 'async_trait, 
[src]

#[must_use]pub fn new<'async_trait, M: TryIntoModel, A: TryIntoAdapter>(
    m: M,
    a: A
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>> where
    Self: Sized,
    M: 'async_trait,
    A: 'async_trait,
    Self: 'async_trait, 
[src]

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

pub fn get_model(&self) -> &dyn Model[src]

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

pub fn get_adapter(&self) -> &dyn Adapter[src]

pub fn get_mut_adapter(&mut self) -> &mut dyn Adapter[src]

pub fn get_role_manager(&self) -> Arc<RwLock<dyn RoleManager>>[src]

pub fn set_role_manager(
    &mut self,
    rm: Arc<RwLock<dyn RoleManager>>
) -> Result<()>
[src]

#[must_use]pub fn set_model<'life0, 'async_trait, M: TryIntoModel>(
    &'life0 mut self,
    m: M
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    Self: Sized,
    M: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

#[must_use]pub fn set_adapter<'life0, 'async_trait, A: TryIntoAdapter>(
    &'life0 mut self,
    a: A
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    Self: Sized,
    A: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

pub fn set_effector(&mut self, e: Box<dyn Effector>)[src]

pub fn enforce<ARGS: EnforceArgs>(&self, rvals: ARGS) -> Result<bool> where
    Self: Sized
[src]

pub fn enforce_mut<ARGS: EnforceArgs>(&mut self, rvals: ARGS) -> Result<bool> where
    Self: Sized
[src]

#[must_use]pub fn load_policy<'life0, 'async_trait>(
    &'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

#[must_use]pub fn load_filtered_policy<'a, 'life0, 'async_trait>(
    &'life0 mut self,
    f: Filter<'a>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    'a: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

pub fn is_filtered(&self) -> bool[src]

pub fn is_enabled(&self) -> bool[src]

#[must_use]pub fn save_policy<'life0, 'async_trait>(
    &'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

#[must_use]pub fn clear_policy<'life0, 'async_trait>(
    &'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

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

pub fn enable_enforce(&mut self, enabled: bool)[src]

pub fn has_auto_save_enabled(&self) -> bool[src]

Loading content...

Implementors

impl CoreApi for Enforcer[src]

pub fn enforce<ARGS: EnforceArgs>(&self, rvals: ARGS) -> 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::prelude::*;
#[cfg(feature = "runtime-async-std")]
#[async_std::main]
async fn main() -> Result<()> {
    let mut e = Enforcer::new("examples/basic_model.conf", "examples/basic_policy.csv").await?;
    assert_eq!(true, e.enforce(("alice", "data1", "read"))?);
    Ok(())
}

#[cfg(feature = "runtime-tokio")]
#[tokio::main]
async fn main() -> Result<()> {
    let mut e = Enforcer::new("examples/basic_model.conf", "examples/basic_policy.csv").await?;
    assert_eq!(true, e.enforce(("alice", "data1", "read"))?);

    Ok(())
}
#[cfg(all(not(feature = "runtime-async-std"), not(feature = "runtime-tokio")))]
fn main() {}
Loading content...