pub struct StringAdapter { /* private fields */ }
Implementations§
Source§impl StringAdapter
impl StringAdapter
Sourcepub fn new(s: impl ToString) -> Self
pub fn new(s: impl ToString) -> Self
§Examples
let a = StringAdapter::new(
r#"
p, alice, data1, read
p, bob, data2, write
p, data2_admin, data2, read
p, data2_admin, data2, write
g, alice, data2_admin
"#,
);
let e = Enforcer::new(m, a).await?;
assert_eq!(true, e.enforce(("alice", "data1", "read"))?);
assert_eq!(true, e.enforce(("alice", "data2", "read"))?);
assert_eq!(true, e.enforce(("bob", "data2", "write"))?);
assert_eq!(false, e.enforce(("bob", "data1", "write"))?);
Trait Implementations§
Source§impl Adapter for StringAdapter
impl Adapter for StringAdapter
fn load_policy<'life0, 'life1, 'async_trait>(
&'life0 mut self,
m: &'life1 mut dyn Model,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_filtered_policy<'a, 'life0, 'life1, 'async_trait>(
&'life0 mut self,
m: &'life1 mut dyn Model,
f: Filter<'a>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save_policy<'life0, 'life1, 'async_trait>(
&'life0 mut self,
m: &'life1 mut dyn Model,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn clear_policy<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_policy<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_sec: &'life1 str,
_ptype: &'life2 str,
_rule: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn add_policies<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_sec: &'life1 str,
_ptype: &'life2 str,
_rules: Vec<Vec<String>>,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn remove_policy<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_sec: &'life1 str,
_ptype: &'life2 str,
_rule: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn remove_policies<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_sec: &'life1 str,
_ptype: &'life2 str,
_rule: Vec<Vec<String>>,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn remove_filtered_policy<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_sec: &'life1 str,
_ptype: &'life2 str,
_field_index: usize,
_field_values: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn is_filtered(&self) -> bool
Source§impl Default for StringAdapter
impl Default for StringAdapter
Source§fn default() -> StringAdapter
fn default() -> StringAdapter
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for StringAdapter
impl RefUnwindSafe for StringAdapter
impl Send for StringAdapter
impl Sync for StringAdapter
impl Unpin for StringAdapter
impl UnwindSafe for StringAdapter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more