pub struct AccessPolicy {
pub default_decision: AccessDecision,
pub tables: BTreeMap<String, TableAccessPolicy>,
}Expand description
Complete access policy set.
Fields§
§default_decision: AccessDecisionDefault decision when no exact or wildcard table policy matches.
tables: BTreeMap<String, TableAccessPolicy>Table policies by table name. "*" is a wildcard fallback.
Implementations§
Source§impl AccessPolicy
impl AccessPolicy
Sourcepub fn allow_by_default() -> Self
pub fn allow_by_default() -> Self
Allow-by-default policy set for trusted/internal use.
Sourcepub fn with_table(
self,
table: impl Into<String>,
policy: TableAccessPolicy,
) -> Self
pub fn with_table( self, table: impl Into<String>, policy: TableAccessPolicy, ) -> Self
Add or replace a table policy.
Sourcepub fn from_toml_str(input: &str) -> Result<Self, AccessPolicyLoadError>
pub fn from_toml_str(input: &str) -> Result<Self, AccessPolicyLoadError>
Parse an access policy from TOML.
Sourcepub fn from_json_str(input: &str) -> Result<Self, AccessPolicyLoadError>
pub fn from_json_str(input: &str) -> Result<Self, AccessPolicyLoadError>
Parse an access policy from JSON.
Sourcepub fn load_from_path(
path: impl AsRef<Path>,
) -> Result<Self, AccessPolicyLoadError>
pub fn load_from_path( path: impl AsRef<Path>, ) -> Result<Self, AccessPolicyLoadError>
Load an access policy from a .toml or .json file.
Sourcepub fn table_mut(&mut self, table: impl Into<String>) -> &mut TableAccessPolicy
pub fn table_mut(&mut self, table: impl Into<String>) -> &mut TableAccessPolicy
Mutably access a table policy, creating an empty policy if needed.
Source§impl AccessPolicy
impl AccessPolicy
Sourcepub fn check_command(
&self,
ctx: &AccessContext,
cmd: &Qail,
) -> Result<(), AccessError>
pub fn check_command( &self, ctx: &AccessContext, cmd: &Qail, ) -> Result<(), AccessError>
Check whether a command is allowed for the supplied context.
Trait Implementations§
Source§impl Clone for AccessPolicy
impl Clone for AccessPolicy
Source§fn clone(&self) -> AccessPolicy
fn clone(&self) -> AccessPolicy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AccessPolicy
impl Debug for AccessPolicy
Source§impl Default for AccessPolicy
impl Default for AccessPolicy
Source§impl<'de> Deserialize<'de> for AccessPolicy
impl<'de> Deserialize<'de> for AccessPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for AccessPolicy
Source§impl PartialEq for AccessPolicy
impl PartialEq for AccessPolicy
Source§fn eq(&self, other: &AccessPolicy) -> bool
fn eq(&self, other: &AccessPolicy) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for AccessPolicy
impl Serialize for AccessPolicy
impl StructuralPartialEq for AccessPolicy
Auto Trait Implementations§
impl Freeze for AccessPolicy
impl RefUnwindSafe for AccessPolicy
impl Send for AccessPolicy
impl Sync for AccessPolicy
impl Unpin for AccessPolicy
impl UnsafeUnpin for AccessPolicy
impl UnwindSafe for AccessPolicy
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