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/disambiguatedN
=InternalName
: All references to entity/common types have been resolved into fully-qualifiedInternalName
s
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>
impl<N, A> ValidatorNamespaceDef<N, A>
Sourcepub fn all_declared_entity_type_names(
&self,
) -> impl Iterator<Item = &InternalName>
pub fn all_declared_entity_type_names( &self, ) -> impl Iterator<Item = &InternalName>
Get the fully-qualified InternalName
s of all entity types declared
in this ValidatorNamespaceDef
.
Sourcepub fn all_declared_common_type_names(
&self,
) -> impl Iterator<Item = &InternalName>
pub fn all_declared_common_type_names( &self, ) -> impl Iterator<Item = &InternalName>
Get the fully-qualified InternalName
s of all common types declared
in this ValidatorNamespaceDef
.
Sourcepub fn all_declared_action_names(&self) -> impl Iterator<Item = &EntityUID>
pub fn all_declared_action_names(&self) -> impl Iterator<Item = &EntityUID>
Get the fully-qualified EntityUID
s of all actions declared in this
ValidatorNamespaceDef
.
Sourcepub fn namespace(&self) -> Option<&InternalName>
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>
impl ValidatorNamespaceDef<ConditionalName, ConditionalName>
Sourcepub fn from_namespace_definition(
namespace: Option<InternalName>,
namespace_def: NamespaceDefinition<RawName>,
action_behavior: ActionBehavior,
extensions: &Extensions<'_>,
) -> Result<ValidatorNamespaceDef<ConditionalName, ConditionalName>>
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
]
Sourcepub fn from_common_type_defs(
namespace: Option<InternalName>,
defs: HashMap<UnreservedId, Type<ConditionalName>>,
) -> Result<ValidatorNamespaceDef<ConditionalName, ConditionalName>>
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 ConditionalName
s.
Sourcepub fn from_common_type_def(
namespace: Option<InternalName>,
def: (UnreservedId, Type<ConditionalName>),
) -> ValidatorNamespaceDef<ConditionalName, ConditionalName>
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 ConditionalName
s.
Unlike from_common_type_defs()
, this function cannot fail, because
there is only one def so it cannot have a name collision with itself
Sourcepub fn fully_qualify_type_references(
self,
all_defs: &AllDefs,
) -> Result<ValidatorNamespaceDef<InternalName, EntityType>, SchemaError>
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§
Auto Trait Implementations§
impl<N, A> Freeze for ValidatorNamespaceDef<N, A>
impl<N, A> RefUnwindSafe for ValidatorNamespaceDef<N, A>where
N: RefUnwindSafe,
A: RefUnwindSafe,
impl<N, A> Send for ValidatorNamespaceDef<N, A>
impl<N, A> Sync for ValidatorNamespaceDef<N, A>
impl<N, A> Unpin for ValidatorNamespaceDef<N, A>
impl<N, A> UnwindSafe for ValidatorNamespaceDef<N, A>
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> 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