Struct cedar_policy_core::entities::EntityJsonParser
source · pub struct EntityJsonParser<'e, S: Schema = NoEntitiesSchema> { /* private fields */ }
Expand description
Struct used to parse entities from JSON.
Implementations§
source§impl<'e, S: Schema> EntityJsonParser<'e, S>
impl<'e, S: Schema> EntityJsonParser<'e, S>
sourcepub fn new(
schema: Option<S>,
extensions: Extensions<'e>,
tc_computation: TCComputation
) -> Self
pub fn new( schema: Option<S>, extensions: Extensions<'e>, tc_computation: TCComputation ) -> Self
Create a new EntityJsonParser
.
If a schema
is present, this will inform the parsing: for instance, it
will allow __entity
and __extn
escapes to be implicit.
It will also ensure that the produced Entities
fully conforms to the
schema
– for instance, it will error if attributes have the wrong
types (e.g., string instead of integer), or if required attributes are
missing or superfluous attributes are provided.
If you pass TCComputation::AssumeAlreadyComputed
, then the caller is
responsible for ensuring that TC holds before calling this method.
sourcepub fn from_json_str(&self, json: &str) -> Result<Entities, EntitiesError>
pub fn from_json_str(&self, json: &str) -> Result<Entities, EntitiesError>
Parse an entities JSON file (in &str
form) into an Entities
object
sourcepub fn from_json_value(&self, json: Value) -> Result<Entities, EntitiesError>
pub fn from_json_value(&self, json: Value) -> Result<Entities, EntitiesError>
Parse an entities JSON file (in serde_json::Value
form) into an Entities
object
sourcepub fn from_json_file(&self, json: impl Read) -> Result<Entities, EntitiesError>
pub fn from_json_file(&self, json: impl Read) -> Result<Entities, EntitiesError>
Parse an entities JSON file (in std::io::Read
form) into an Entities
object