pub struct Fragment<N>(pub BTreeMap<Option<Name>, NamespaceDefinition<N>>);
Expand description
A Fragment
is split into multiple namespace definitions, and is just a
map from namespace name to namespace definition (i.e., definitions of common
types, entity types, and actions in that namespace).
The namespace name is implicitly applied to all definitions in the
corresponding [NamespaceDefinition
].
See [NamespaceDefinition
].
The parameter N
is the type of entity type names and common type names in
attributes/parents fields in this Fragment
, including recursively. (It
doesn’t affect the type of common and entity type names that are being
declared here, which is always an UnreservedId
and unambiguously refers
to the InternalName
with the appropriate implicit namespace prepended.
It only affects the type of common and entity type references.)
For example:
N
=RawName
: This is the schema JSON format exposed to usersN
=ConditionalName
: aFragment
which has been partially processed, by convertingRawName
s intoConditionalName
sN
=InternalName
: aFragment
in which all names have been resolved into fully-qualifiedInternalName
s
Tuple Fields§
§0: BTreeMap<Option<Name>, NamespaceDefinition<N>>
Implementations§
Source§impl Fragment<RawName>
impl Fragment<RawName>
Sourcepub fn from_json_str(json: &str) -> Result<Self>
pub fn from_json_str(json: &str) -> Result<Self>
Create a Fragment
from a string containing JSON (which should
be an object of the appropriate shape).
Sourcepub fn from_json_value(json: Value) -> Result<Self>
pub fn from_json_value(json: Value) -> Result<Self>
Create a Fragment
from a JSON value (which should be an object
of the appropriate shape).
Sourcepub fn from_json_file(file: impl Read) -> Result<Self>
pub fn from_json_file(file: impl Read) -> Result<Self>
Create a Fragment
directly from a file containing a JSON object.
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>
Parse the schema (in the Cedar schema syntax) from a string
Sourcepub fn from_cedarschema_file<'a>(
file: impl Read,
extensions: &'a Extensions<'_>,
) -> Result<(Self, impl Iterator<Item = SchemaWarning> + 'a), CedarSchemaError>
pub fn from_cedarschema_file<'a>( file: impl Read, extensions: &'a Extensions<'_>, ) -> Result<(Self, impl Iterator<Item = SchemaWarning> + 'a), CedarSchemaError>
Parse the schema (in the Cedar schema syntax) from a reader
Source§impl<N: Display> Fragment<N>
impl<N: Display> Fragment<N>
Sourcepub fn to_cedarschema(&self) -> Result<String, ToCedarSchemaSyntaxError>
pub fn to_cedarschema(&self) -> Result<String, ToCedarSchemaSyntaxError>
Pretty print this Fragment
Trait Implementations§
Source§impl<'de, N> Deserialize<'de> for Fragment<N>
impl<'de, N> Deserialize<'de> for Fragment<N>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl TryInto<ValidatorSchemaFragment<ConditionalName, ConditionalName>> for Fragment<RawName>
impl TryInto<ValidatorSchemaFragment<ConditionalName, ConditionalName>> for Fragment<RawName>
Source§type Error = SchemaError
type Error = SchemaError
Source§fn try_into(
self,
) -> Result<ValidatorSchemaFragment<ConditionalName, ConditionalName>>
fn try_into( self, ) -> Result<ValidatorSchemaFragment<ConditionalName, ConditionalName>>
impl<N> StructuralPartialEq for Fragment<N>
Auto Trait Implementations§
impl<N> Freeze for Fragment<N>
impl<N> RefUnwindSafe for Fragment<N>where
N: RefUnwindSafe,
impl<N> Send for Fragment<N>where
N: Send,
impl<N> Sync for Fragment<N>where
N: Sync,
impl<N> Unpin for Fragment<N>
impl<N> UnwindSafe for Fragment<N>where
N: RefUnwindSafe,
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