pub struct PolicySet { /* private fields */ }Expand description
Represents a set of Policys
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 merge_policyset(
&mut self,
other: &PolicySet,
rename_duplicates: bool,
) -> Result<LinkedHashMap<PolicyID, PolicyID>, PolicySetError>
pub fn merge_policyset( &mut self, other: &PolicySet, rename_duplicates: bool, ) -> Result<LinkedHashMap<PolicyID, PolicyID>, PolicySetError>
Merges this PolicySet with another PolicySet.
This PolicySet is modified while the other PolicySet
remains unchanged.
The flag rename_duplicates controls the expected behavior
when a PolicyID in this and the other PolicySet conflict.
When rename_duplicates is false, conflicting PolicyIDs result
in a occupied PolicySetError.
Otherwise, when rename_duplicates is true, conflicting PolicyIDs from
the other PolicySet are automatically renamed to avoid conflict.
This renaming is returned as a Hashmap from the old PolicyID to the
renamed PolicyID.
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 into_policies(self) -> impl Iterator<Item = Policy>
pub fn into_policies(self) -> impl Iterator<Item = Policy>
Consume the PolicySet, producing an iterator of all the policies in it
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 From<PolicySet> for LiteralPolicySet
impl From<PolicySet> for LiteralPolicySet
Source§impl TryFrom<LiteralPolicySet> for PolicySet
Converts a LiteralPolicySet into a PolicySet, ensuring the invariants are met
Every Policy must point to a Template that exists in the set.
impl TryFrom<LiteralPolicySet> for PolicySet
Converts a LiteralPolicySet into a PolicySet, ensuring the invariants are met
Every Policy must point to a Template that exists in the set.
Source§type Error = ReificationError
type Error = ReificationError
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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