Struct casbin::prelude::Enforcer[][src]

pub struct Enforcer { /* fields omitted */ }
Expand description

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

Trait Implementations

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() {}

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.