Struct cedar_policy_core::entities::Entities
source · pub struct Entities { /* private fields */ }
Expand description
Represents an entity hierarchy, and allows looking up Entity
objects by
UID.
Note that Entities
is Serialize
, but currently this is only used for the
FFI layer in DRT. All others use (and should use) the from_json_*()
and
write_to_json()
methods as necessary.
Implementations§
source§impl Entities
impl Entities
sourcepub fn entity(&self, uid: &EntityUID) -> Dereference<'_, Entity>
pub fn entity(&self, uid: &EntityUID) -> Dereference<'_, Entity>
Get the Entity
with the given UID, if any
sourcepub fn add_entities(
self,
collection: impl IntoIterator<Item = Entity>,
schema: Option<&impl Schema>,
tc_computation: TCComputation,
extensions: Extensions<'_>
) -> Result<Self>
pub fn add_entities( self, collection: impl IntoIterator<Item = Entity>, schema: Option<&impl Schema>, tc_computation: TCComputation, extensions: Extensions<'_> ) -> Result<Self>
Adds the crate::ast::Entity
s in the iterator to this Entities
.
Fails if the passed iterator contains any duplicate entities with this structure,
or if any error is encountered in the transitive closure computation.
If schema
is present, then the added entities will be validated
against the schema
, returning an error if they do not conform to the
schema.
(This method will not add action entities from the schema
.)
If you pass TCComputation::AssumeAlreadyComputed
, then the caller is
responsible for ensuring that TC and DAG hold before calling this method.
sourcepub fn from_entities(
entities: impl IntoIterator<Item = Entity>,
schema: Option<&impl Schema>,
tc_computation: TCComputation,
extensions: Extensions<'_>
) -> Result<Self>
pub fn from_entities( entities: impl IntoIterator<Item = Entity>, schema: Option<&impl Schema>, tc_computation: TCComputation, extensions: Extensions<'_> ) -> Result<Self>
Create an Entities
object with the given entities.
If schema
is present, then action entities from that schema will also
be added to the Entities
.
Also, the entities in entities
will be validated against the schema
,
returning an error if they do not conform to the schema.
If you pass TCComputation::AssumeAlreadyComputed
, then the caller is
responsible for ensuring that TC and DAG hold before calling this method.
sourcepub fn to_json_value(&self) -> Result<Value>
pub fn to_json_value(&self) -> Result<Value>
Convert an Entities
object into a JSON value suitable for parsing in
via EntityJsonParser
.
The returned JSON value will be parse-able even with no Schema
.
To parse an Entities
object from a JSON value, use EntityJsonParser
.
sourcepub fn write_to_json(&self, f: impl Write) -> Result<()>
pub fn write_to_json(&self, f: impl Write) -> Result<()>
Dump an Entities
object into an entities JSON file.
The resulting JSON will be suitable for parsing in via
EntityJsonParser
, and will be parse-able even with no Schema
.
To read an Entities
object from an entities JSON file, use
EntityJsonParser
.
sourcepub fn to_dot_str(&self) -> Result<String, Error>
pub fn to_dot_str(&self) -> Result<String, Error>
Write entities into a DOT graph