pub struct ValidatorSchema { /* private fields */ }
Expand description
Internal representation of the schema for use by the validator.
In this representation, all common types are fully expanded, and all entity type names are fully disambiguated (fully qualified).
Implementations§
Source§impl ValidatorSchema
impl ValidatorSchema
Sourcepub fn principals(&self) -> impl Iterator<Item = &EntityType>
pub fn principals(&self) -> impl Iterator<Item = &EntityType>
Returns an iterator over every entity type that can be a principal for any action in this schema
Sourcepub fn resources(&self) -> impl Iterator<Item = &EntityType>
pub fn resources(&self) -> impl Iterator<Item = &EntityType>
Returns an iterator over every entity type that can be a resource for any action in this schema
Sourcepub fn principals_for_action(
&self,
action: &EntityUID,
) -> Option<impl Iterator<Item = &EntityType>>
pub fn principals_for_action( &self, action: &EntityUID, ) -> Option<impl Iterator<Item = &EntityType>>
Sourcepub fn resources_for_action(
&self,
action: &EntityUID,
) -> Option<impl Iterator<Item = &EntityType>>
pub fn resources_for_action( &self, action: &EntityUID, ) -> Option<impl Iterator<Item = &EntityType>>
Sourcepub fn ancestors<'a>(
&'a self,
ty: &'a EntityType,
) -> Option<impl Iterator<Item = &EntityType> + 'a>
pub fn ancestors<'a>( &'a self, ty: &'a EntityType, ) -> Option<impl Iterator<Item = &EntityType> + 'a>
Sourcepub fn action_groups(&self) -> impl Iterator<Item = &EntityUID>
pub fn action_groups(&self) -> impl Iterator<Item = &EntityUID>
Returns an iterator over all the action groups defined in this schema
Sourcepub fn actions(&self) -> impl Iterator<Item = &EntityUID>
pub fn actions(&self) -> impl Iterator<Item = &EntityUID>
Returns an iterator over all actions defined in this schema
Sourcepub fn empty() -> ValidatorSchema
pub fn empty() -> ValidatorSchema
Create a ValidatorSchema
without any definitions (of entity types,
common types, or actions).
Sourcepub fn from_json_value(json: Value, extensions: &Extensions<'_>) -> Result<Self>
pub fn from_json_value(json: Value, extensions: &Extensions<'_>) -> Result<Self>
Construct a ValidatorSchema
from a JSON value in the appropriate
shape.
Sourcepub fn from_json_str(json: &str, extensions: &Extensions<'_>) -> Result<Self>
pub fn from_json_str(json: &str, extensions: &Extensions<'_>) -> Result<Self>
Construct a ValidatorSchema
from a string containing JSON in the
appropriate shape.
Sourcepub fn from_json_file(
file: impl Read,
extensions: &Extensions<'_>,
) -> Result<Self>
pub fn from_json_file( file: impl Read, extensions: &Extensions<'_>, ) -> Result<Self>
Construct a ValidatorSchema
directly from a file containing JSON
in the appropriate shape.
Sourcepub fn from_cedarschema_file<'a>(
r: impl Read,
extensions: &'a Extensions<'a>,
) -> Result<(Self, impl Iterator<Item = SchemaWarning> + 'a), CedarSchemaError>
pub fn from_cedarschema_file<'a>( r: impl Read, extensions: &'a Extensions<'a>, ) -> Result<(Self, impl Iterator<Item = SchemaWarning> + 'a), CedarSchemaError>
Construct a ValidatorSchema
directly from a file containing the
Cedar schema syntax.
Sourcepub fn from_cedarschema_str<'a>(
src: &str,
extensions: &Extensions<'a>,
) -> Result<(Self, impl Iterator<Item = SchemaWarning> + 'a), CedarSchemaError>
pub fn from_cedarschema_str<'a>( src: &str, extensions: &Extensions<'a>, ) -> Result<(Self, impl Iterator<Item = SchemaWarning> + 'a), CedarSchemaError>
Construct a ValidatorSchema
from a string containing the Cedar
schema syntax.
Sourcepub fn from_schema_fragments(
fragments: impl IntoIterator<Item = ValidatorSchemaFragment<ConditionalName, ConditionalName>>,
extensions: &Extensions<'_>,
) -> Result<ValidatorSchema>
pub fn from_schema_fragments( fragments: impl IntoIterator<Item = ValidatorSchemaFragment<ConditionalName, ConditionalName>>, extensions: &Extensions<'_>, ) -> Result<ValidatorSchema>
Construct a ValidatorSchema
from some number of ValidatorSchemaFragment
s.
Sourcepub fn get_action_id(&self, action_id: &EntityUID) -> Option<&ValidatorActionId>
pub fn get_action_id(&self, action_id: &EntityUID) -> Option<&ValidatorActionId>
Lookup the ValidatorActionId
object in the schema with the given name.
Sourcepub fn get_entity_type<'a>(
&'a self,
entity_type_id: &EntityType,
) -> Option<&'a ValidatorEntityType>
pub fn get_entity_type<'a>( &'a self, entity_type_id: &EntityType, ) -> Option<&'a ValidatorEntityType>
Lookup the ValidatorEntityType
object in the schema with the given name.
Sourcepub fn entity_types(
&self,
) -> impl Iterator<Item = (&EntityType, &ValidatorEntityType)>
pub fn entity_types( &self, ) -> impl Iterator<Item = (&EntityType, &ValidatorEntityType)>
An iterator matching the entity Types to their Validator Types
Sourcepub fn context_type(&self, action: &EntityUID) -> Option<&Type>
pub fn context_type(&self, action: &EntityUID) -> Option<&Type>
Get the Type
of context expected for the given action
.
This always returns a closed record type.
Returns None
if the action is not in the schema.
Sourcepub fn action_entities(&self) -> Result<Entities, EntitiesError>
pub fn action_entities(&self) -> Result<Entities, EntitiesError>
Construct an Entity
object for each action in the schema
Trait Implementations§
Source§impl Clone for ValidatorSchema
impl Clone for ValidatorSchema
Source§fn clone(&self) -> ValidatorSchema
fn clone(&self) -> ValidatorSchema
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ValidatorSchema
impl Debug for ValidatorSchema
Source§impl FromStr for ValidatorSchema
impl FromStr for ValidatorSchema
Construct ValidatorSchema
from a string containing a schema formatted
in the Cedar schema format.
Source§impl RequestSchema for ValidatorSchema
impl RequestSchema for ValidatorSchema
Source§type Error = RequestValidationError
type Error = RequestValidationError
Source§fn validate_request(
&self,
request: &Request,
extensions: &Extensions<'_>,
) -> Result<(), Self::Error>
fn validate_request( &self, request: &Request, extensions: &Extensions<'_>, ) -> Result<(), Self::Error>
request
, returning Err
if it fails validationSource§impl Serialize for ValidatorSchema
impl Serialize for ValidatorSchema
Auto Trait Implementations§
impl Freeze for ValidatorSchema
impl RefUnwindSafe for ValidatorSchema
impl Send for ValidatorSchema
impl Sync for ValidatorSchema
impl Unpin for ValidatorSchema
impl UnwindSafe for ValidatorSchema
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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