pub struct Schema { /* private fields */ }Expand description
Schema
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn schema_fragment_for_canister(
&self,
canister_path: &str,
) -> Result<SchemaFragment, FragmentLoweringError>
pub fn schema_fragment_for_canister( &self, canister_path: &str, ) -> Result<SchemaFragment, FragmentLoweringError>
Lower every persisted entity belonging to one canister, plus its exact reachable named-type and relation closure, into one store-free fragment.
Store assignment remains a later proposal-composition concern.
§Errors
Returns a typed error when the graph is not sealed, the selected canister/store closure is incomplete, or one authored fact cannot be represented by the bounded public proposal contract.
Source§impl Schema
impl Schema
pub const fn new() -> Self
Sourcepub fn insert_node(&mut self, node: SchemaNode)
pub fn insert_node(&mut self, node: SchemaNode)
Register one constructor-produced node while the graph is collecting.
Duplicate and late registration are retained as graph errors rather
than replacing an earlier declaration. crate::build::get_schema
reports the lexically canonical retained error before exposing a sealed
snapshot.
Sourcepub const fn is_sealed(&self) -> bool
pub const fn is_sealed(&self) -> bool
Return whether whole-graph validation has sealed this graph.
Sourcepub const fn digest(&self) -> Option<SchemaGraphDigest>
pub const fn digest(&self) -> Option<SchemaGraphDigest>
Return the immutable digest of a sealed graph.
pub fn get_node<'a>(&'a self, path: &str) -> Option<&'a SchemaNode>
pub fn try_get_node<'a>(&'a self, path: &str) -> Result<&'a SchemaNode, Error>
pub fn cast_node<'a, T: 'static>(&'a self, path: &str) -> Result<&'a T, Error>
pub fn get_nodes<T: 'static>(&self) -> impl Iterator<Item = (&str, &T)>
pub fn filter_nodes<'a, T: 'static>( &'a self, predicate: impl Fn(&T) -> bool + 'a, ) -> impl Iterator<Item = (&'a str, &'a T)> + 'a
Sourcepub const fn nodes(&self) -> &BTreeMap<String, SchemaNode>
pub const fn nodes(&self) -> &BTreeMap<String, SchemaNode>
Borrow all schema nodes indexed by path.
Sourcepub fn enum_unit_literal(
&self,
enum_path: &str,
variant_name: &str,
) -> Result<ScalarLiteral, SchemaContractError>
pub fn enum_unit_literal( &self, enum_path: &str, variant_name: &str, ) -> Result<ScalarLiteral, SchemaContractError>
Resolve one authored unit-enum literal through current declared names.
§Errors
Returns an invalid-enum-literal error when the path is not an enum, the variant is absent, or either maintained name is malformed.