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