pub struct PolicySet { /* private fields */ }
Expand description
Represents a set of Policy
s
Implementations§
Source§impl PolicySet
impl PolicySet
Sourcepub fn add(&mut self, policy: Policy) -> Result<(), PolicySetError>
pub fn add(&mut self, policy: Policy) -> Result<(), PolicySetError>
Add a Policy
to the PolicySet
.
Sourcepub fn remove_static(
&mut self,
policy_id: &PolicyID,
) -> Result<Policy, PolicySetPolicyRemovalError>
pub fn remove_static( &mut self, policy_id: &PolicyID, ) -> Result<Policy, PolicySetPolicyRemovalError>
Remove a static Policy`` from the
PolicySet`.
Sourcepub fn add_static(&mut self, policy: StaticPolicy) -> Result<(), PolicySetError>
pub fn add_static(&mut self, policy: StaticPolicy) -> Result<(), PolicySetError>
Add a StaticPolicy
to the PolicySet
.
Sourcepub fn add_template(&mut self, t: Template) -> Result<(), PolicySetError>
pub fn add_template(&mut self, t: Template) -> Result<(), PolicySetError>
Add a template to the policy set. If a link, static policy or template with the same name already exists, this will error.
Sourcepub fn remove_template(
&mut self,
policy_id: &PolicyID,
) -> Result<Template, PolicySetTemplateRemovalError>
pub fn remove_template( &mut self, policy_id: &PolicyID, ) -> Result<Template, PolicySetTemplateRemovalError>
Remove a template from the policy set.
This will error if any policy is linked to the template.
This will error if policy_id
is not a template.
Sourcepub fn get_linked_policies(
&self,
template_id: &PolicyID,
) -> Result<impl Iterator<Item = &PolicyID>, PolicySetGetLinksError>
pub fn get_linked_policies( &self, template_id: &PolicyID, ) -> Result<impl Iterator<Item = &PolicyID>, PolicySetGetLinksError>
Get the list of policies linked to template_id
.
Returns all p in links
s.t. p.template().id() == template_id
Sourcepub fn link(
&mut self,
template_id: PolicyID,
new_id: PolicyID,
values: HashMap<SlotId, EntityUID>,
) -> Result<&Policy, LinkingError>
pub fn link( &mut self, template_id: PolicyID, new_id: PolicyID, values: HashMap<SlotId, EntityUID>, ) -> Result<&Policy, LinkingError>
Attempt to create a new template linked policy and add it to the policy set. Returns a references to the new template linked policy if successful.
Errors for two reasons
- The the passed SlotEnv either does not match the slots in the templates
- The passed link Id conflicts with an Id already in the set
Sourcepub fn unlink(
&mut self,
policy_id: &PolicyID,
) -> Result<Policy, PolicySetUnlinkError>
pub fn unlink( &mut self, policy_id: &PolicyID, ) -> Result<Policy, PolicySetUnlinkError>
Unlink policy_id
If it is not a link this will error
Sourcepub fn all_templates(&self) -> impl Iterator<Item = &Template>
pub fn all_templates(&self) -> impl Iterator<Item = &Template>
Iterate over everything stored as template, including static policies. Ie: all_templates() should equal templates() ++ static_policies().map(|p| p.template())
Sourcepub fn static_policies(&self) -> impl Iterator<Item = &Policy>
pub fn static_policies(&self) -> impl Iterator<Item = &Policy>
Iterate over all of the static policies.
Sourcepub fn get_template_arc(&self, id: &PolicyID) -> Option<Arc<Template>>
pub fn get_template_arc(&self, id: &PolicyID) -> Option<Arc<Template>>
Lookup a template by policy id, returns Option<Arc<Template>>
Sourcepub fn get_template(&self, id: &PolicyID) -> Option<&Template>
pub fn get_template(&self, id: &PolicyID) -> Option<&Template>
Lookup a template by policy id, returns Option<&Template>
Sourcepub fn try_from_iter<T: IntoIterator<Item = Policy>>(
iter: T,
) -> Result<Self, PolicySetError>
pub fn try_from_iter<T: IntoIterator<Item = Policy>>( iter: T, ) -> Result<Self, PolicySetError>
Attempt to collect an iterator over policies into a PolicySet
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PolicySet
impl<'de> Deserialize<'de> for PolicySet
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>,
impl Eq for PolicySet
impl StructuralPartialEq for PolicySet
Auto Trait Implementations§
impl Freeze for PolicySet
impl RefUnwindSafe for PolicySet
impl Send for PolicySet
impl Sync for PolicySet
impl Unpin for PolicySet
impl UnwindSafe for PolicySet
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more