Struct cedar_policy::Entities
source · #[repr(transparent)]pub struct Entities(_);
Expand description
Represents an entity hierarchy, and allows looking up Entity
objects by
Uid.
Implementations§
source§impl Entities
impl Entities
sourcepub fn get(&self, uid: &EntityUid) -> Option<&Entity>
pub fn get(&self, uid: &EntityUid) -> Option<&Entity>
Get the Entity
with the given Uid, if any
sourcepub fn from_entities(
entities: impl IntoIterator<Item = Entity>
) -> Result<Self, EntitiesError>
pub fn from_entities( entities: impl IntoIterator<Item = Entity> ) -> Result<Self, EntitiesError>
Create an Entities
object with the given entities
It will error if the entities cannot be read or if the entities hierarchy is cyclic
sourcepub fn from_json_str(
json: &str,
schema: Option<&Schema>
) -> Result<Self, EntitiesError>
pub fn from_json_str( json: &str, schema: Option<&Schema> ) -> Result<Self, EntitiesError>
Parse an entities JSON file (in &str
form) into an Entities
object
If a schema
is provided, this will inform the parsing: for instance, it
will allow __entity
and __extn
escapes to be implicit, and it will error
if attributes have the wrong types (e.g., string instead of integer).
sourcepub fn from_json_value(
json: Value,
schema: Option<&Schema>
) -> Result<Self, EntitiesError>
pub fn from_json_value( json: Value, schema: Option<&Schema> ) -> Result<Self, EntitiesError>
Parse an entities JSON file (in serde_json::Value
form) into an
Entities
object
If a schema
is provided, this will inform the parsing: for instance, it
will allow __entity
and __extn
escapes to be implicit, and it will error
if attributes have the wrong types (e.g., string instead of integer).
sourcepub fn from_json_file(
json: impl Read,
schema: Option<&Schema>
) -> Result<Self, EntitiesError>
pub fn from_json_file( json: impl Read, schema: Option<&Schema> ) -> Result<Self, EntitiesError>
Parse an entities JSON file (in std::io::Read
form) into an Entities
object
If a schema
is provided, this will inform the parsing: for instance, it
will allow __entity
and __extn
escapes to be implicit, and it will error
if attributes have the wrong types (e.g., string instead of integer).
sourcepub fn is_ancestor_of(&self, a: &EntityUid, b: &EntityUid) -> bool
pub fn is_ancestor_of(&self, a: &EntityUid, b: &EntityUid) -> bool
Is entity a
an ancestor of entity b
?
Same semantics as b in a
in the Cedar language
sourcepub fn ancestors<'a>(
&'a self,
euid: &EntityUid
) -> Option<impl Iterator<Item = &'a EntityUid>>
pub fn ancestors<'a>( &'a self, euid: &EntityUid ) -> Option<impl Iterator<Item = &'a EntityUid>>
Get an iterator over the ancestors of the given Euid.
Returns None
if the given Euid
does not exist.
sourcepub fn write_to_json(&self, f: impl Write) -> Result<(), EntitiesError>
pub fn write_to_json(&self, f: impl Write) -> Result<(), EntitiesError>
Dump an Entities
object into an entities JSON file.
The resulting JSON will be suitable for parsing in via
from_json_*
, and will be parse-able even with no Schema
.
To read an Entities
object from an entities JSON file, use
from_json_file
.
Trait Implementations§
source§impl PartialEq<Entities> for Entities
impl PartialEq<Entities> for Entities
impl Eq for Entities
impl StructuralEq for Entities
impl StructuralPartialEq for Entities
Auto Trait Implementations§
impl RefUnwindSafe for Entities
impl Send for Entities
impl Sync for Entities
impl Unpin for Entities
impl UnwindSafe for Entities
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
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.