pub struct PolicyRule {
pub source_type: &'static str,
pub target_type: &'static str,
pub permissions: [Permission; 3],
pub perm_count: u8,
pub action: PolicyAction,
pub enabled: bool,
}Expand description
Security policy rule.
Uses fixed-size arrays and &'static str to avoid heap allocations.
Fields§
§source_type: &'static strSource domain/type
target_type: &'static strTarget domain/type
permissions: [Permission; 3]Allowed/denied permission set (fixed-size array)
perm_count: u8Number of active permissions in the array
action: PolicyActionWhether this rule allows or denies
enabled: boolRule enabled
Implementations§
Source§impl PolicyRule
impl PolicyRule
Sourcepub const fn new(
source_type: &'static str,
target_type: &'static str,
permissions: [Permission; 3],
perm_count: u8,
action: PolicyAction,
) -> Self
pub const fn new( source_type: &'static str, target_type: &'static str, permissions: [Permission; 3], perm_count: u8, action: PolicyAction, ) -> Self
Create a new policy rule with the given action.
Sourcepub fn from_perms(
source_type: &'static str,
target_type: &'static str,
perms: &[Permission],
action: PolicyAction,
) -> Self
pub fn from_perms( source_type: &'static str, target_type: &'static str, perms: &[Permission], action: PolicyAction, ) -> Self
Create a policy rule from a slice of permissions.
Copies up to MAX_PERMISSIONS permissions into the fixed-size array.
Sourcepub fn from_legacy(
source: &'static str,
target: &'static str,
allowed: u8,
) -> Self
pub fn from_legacy( source: &'static str, target: &'static str, allowed: u8, ) -> Self
Create an Allow rule from a legacy bitmask for backward compatibility.
Sourcepub fn allows(&self, access: AccessType) -> bool
pub fn allows(&self, access: AccessType) -> bool
Check if this rule matches and allows the given access.
Sourcepub fn denies(&self, access: AccessType) -> bool
pub fn denies(&self, access: AccessType) -> bool
Check if this rule explicitly denies the given access.
Trait Implementations§
Source§impl Clone for PolicyRule
impl Clone for PolicyRule
Source§fn clone(&self) -> PolicyRule
fn clone(&self) -> PolicyRule
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PolicyRule
impl Debug for PolicyRule
impl Copy for PolicyRule
Auto Trait Implementations§
impl Freeze for PolicyRule
impl RefUnwindSafe for PolicyRule
impl Send for PolicyRule
impl Sync for PolicyRule
impl Unpin for PolicyRule
impl UnwindSafe for PolicyRule
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)