Struct cedar_policy::Schema
source · #[repr(transparent)]pub struct Schema(_);
Expand description
Object containing schema information used by the validator.
Implementations§
source§impl Schema
impl Schema
sourcepub fn from_schema_fragments(
fragments: impl IntoIterator<Item = SchemaFragment>
) -> Result<Self, SchemaError>
pub fn from_schema_fragments( fragments: impl IntoIterator<Item = SchemaFragment> ) -> Result<Self, SchemaError>
Create a Schema
from multiple SchemaFragment
. The individual
fragments may references entity types that are not declared in that
fragment, but all referenced entity types must be declared in some
fragment.
sourcepub fn from_json_value(json: Value) -> Result<Self, SchemaError>
pub fn from_json_value(json: Value) -> Result<Self, SchemaError>
Create a Schema
from a JSON value (which should be an object of the
shape required for Cedar schemas).
sourcepub fn from_file(file: impl Read) -> Result<Self, SchemaError>
pub fn from_file(file: impl Read) -> Result<Self, SchemaError>
Create a Schema
directly from a file.
Trait Implementations§
source§impl FromStr for Schema
impl FromStr for Schema
source§fn from_str(schema_src: &str) -> Result<Self, Self::Err>
fn from_str(schema_src: &str) -> Result<Self, Self::Err>
Construct a schema from a string containing a schema formatted in the Cedar schema format. This can fail if it is not possible to parse a schema from the strings, or if errors in values in the schema are uncovered after parsing. For instance, when an entity attribute name is found to not be a valid attribute name according to the Cedar grammar.
§type Err = SchemaError
type Err = SchemaError
source§impl TryInto<Schema> for SchemaFragment
impl TryInto<Schema> for SchemaFragment
source§fn try_into(self) -> Result<Schema, Self::Error>
fn try_into(self) -> Result<Schema, Self::Error>
Convert SchemaFragment
into a Schema
. To build the Schema
we
need to have all entity types defined, so an error will be returned if
any undeclared entity types are referenced in the schema fragment.