cedar_policy_validator

Struct ValidatorNamespaceDef

Source
pub struct ValidatorNamespaceDef<N, A> { /* private fields */ }
Expand description

A single namespace definition from the schema JSON or Cedar syntax, processed into a form which is closer to that used by the validator. The processing includes detection of some errors, for example, parse errors in entity/common type names or entity/common types which are declared multiple times.

In this representation, there may still be references to undeclared entity/common types, because any entity/common type may be declared in a different fragment that will only be known about when building the complete crate::ValidatorSchema.

The parameter N is the type of entity type names and common type names in attributes/parents fields in this ValidatorNamespaceDef, including recursively. (It doesn’t affect the type of common and entity type names that are being declared here, which are already fully-qualified in this representation. It only affects the type of common and entity type references.) For example:

  • N = ConditionalName: References to entity/common types are not yet fully qualified/disambiguated
  • N = InternalName: All references to entity/common types have been resolved into fully-qualified InternalNames

A is like N, but A governs typenames in appliesTo fields, while N governs all other type references.

Implementations§

Source§

impl<N, A> ValidatorNamespaceDef<N, A>

Source

pub fn all_declared_entity_type_names( &self, ) -> impl Iterator<Item = &InternalName>

Get the fully-qualified InternalNames of all entity types declared in this ValidatorNamespaceDef.

Source

pub fn all_declared_common_type_names( &self, ) -> impl Iterator<Item = &InternalName>

Get the fully-qualified InternalNames of all common types declared in this ValidatorNamespaceDef.

Source

pub fn all_declared_action_names(&self) -> impl Iterator<Item = &EntityUID>

Get the fully-qualified EntityUIDs of all actions declared in this ValidatorNamespaceDef.

Source

pub fn namespace(&self) -> Option<&InternalName>

The fully-qualified InternalName of the namespace this is a definition of. None indicates this definition is for the empty namespace.

Source§

impl ValidatorNamespaceDef<ConditionalName, ConditionalName>

Source

pub fn from_namespace_definition( namespace: Option<InternalName>, namespace_def: NamespaceDefinition<RawName>, action_behavior: ActionBehavior, extensions: &Extensions<'_>, ) -> Result<ValidatorNamespaceDef<ConditionalName, ConditionalName>>

Construct a new ValidatorNamespaceDef<ConditionalName> from the raw [json_schema::NamespaceDefinition]

Source

pub fn from_common_type_defs( namespace: Option<InternalName>, defs: HashMap<UnreservedId, Type<ConditionalName>>, ) -> Result<ValidatorNamespaceDef<ConditionalName, ConditionalName>>

Construct a new ValidatorNamespaceDef<ConditionalName> containing only the given common-type definitions, which are already given in terms of ConditionalNames.

Source

pub fn from_common_type_def( namespace: Option<InternalName>, def: (UnreservedId, Type<ConditionalName>), ) -> ValidatorNamespaceDef<ConditionalName, ConditionalName>

Construct a new ValidatorNamespaceDef<ConditionalName> containing only a single given common-type definition, which is already given in terms of ConditionalNames.

Unlike from_common_type_defs(), this function cannot fail, because there is only one def so it cannot have a name collision with itself

Source

pub fn fully_qualify_type_references( self, all_defs: &AllDefs, ) -> Result<ValidatorNamespaceDef<InternalName, EntityType>, SchemaError>

Convert this ValidatorNamespaceDef<ConditionalName> into a ValidatorNamespaceDef<InternalName> by fully-qualifying all typenames that appear anywhere in any definitions.

all_defs needs to contain the full set of all fully-qualified typenames and actions that are defined in the schema (in all schema fragments).

Trait Implementations§

Source§

impl<N: Debug, A: Debug> Debug for ValidatorNamespaceDef<N, A>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<N, A> Freeze for ValidatorNamespaceDef<N, A>

§

impl<N, A> RefUnwindSafe for ValidatorNamespaceDef<N, A>

§

impl<N, A> Send for ValidatorNamespaceDef<N, A>
where N: Send, A: Send,

§

impl<N, A> Sync for ValidatorNamespaceDef<N, A>
where N: Sync, A: Sync,

§

impl<N, A> Unpin for ValidatorNamespaceDef<N, A>
where N: Unpin, A: Unpin,

§

impl<N, A> UnwindSafe for ValidatorNamespaceDef<N, A>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.