Struct cedar_policy_core::entities::EntityJsonParser
source · pub struct EntityJsonParser<'e, 's, S: Schema = NullSchema> { /* private fields */ }
Expand description
Struct used to parse entities from JSON.
Implementations§
source§impl<'e, 's, S: Schema> EntityJsonParser<'e, 's, S>
impl<'e, 's, S: Schema> EntityJsonParser<'e, 's, S>
sourcepub fn new(
schema: Option<&'s S>,
extensions: Extensions<'e>,
tc_computation: TCComputation
) -> Self
pub fn new( schema: Option<&'s S>, extensions: Extensions<'e>, tc_computation: TCComputation ) -> Self
Create a new EntityJsonParser
.
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).
That does not mean it will fully enforce that the produced Entities
conform to the schema
– for instance, as of this writing, it will not
error for unexpected (additional) record attributes.
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