Struct cedar_policy::Schema

source ·
pub struct Schema(/* private fields */);
Expand description

Object containing schema information used by the validator.

Implementations§

source§

impl Schema

source

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.

source

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).

source

pub fn from_file(file: impl Read) -> Result<Self, SchemaError>

Create a Schema directly from a file.

source

pub fn from_file_natural( file: impl Read ) -> Result<(Self, impl Iterator<Item = SchemaWarning>), HumanSchemaError>

Parse the schema from a reader

source

pub fn from_str_natural( src: &str ) -> Result<(Self, impl Iterator<Item = SchemaWarning>), HumanSchemaError>

Parse the schema from a string

source

pub fn action_entities(&self) -> Result<Entities, EntitiesError>

Extract from the schema an Entities containing the action entities declared in the schema.

Trait Implementations§

source§

impl Clone for Schema

source§

fn clone(&self) -> Schema

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Schema

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FromStr for Schema

source§

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

The associated error which can be returned from parsing.
source§

impl RefCast for Schema

§

type From = ValidatorSchema

source§

fn ref_cast(_from: &Self::From) -> &Self

source§

fn ref_cast_mut(_from: &mut Self::From) -> &mut Self

source§

impl TryInto<Schema> for SchemaFragment

source§

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.

§

type Error = SchemaError

The type returned in the event of a conversion error.

Auto Trait Implementations§

§

impl Freeze for Schema

§

impl RefUnwindSafe for Schema

§

impl Send for Schema

§

impl Sync for Schema

§

impl Unpin for Schema

§

impl UnwindSafe for Schema

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.