pub struct PendingTypes { /* private fields */ }Expand description
Stores information about types that are in the process of being defined.
An ISL type definition can include types that are not yet fully defined. For example, an ISL type definition might include:
- A reference to itself. This could happen in a recursive structure like a linked list or binary tree.
- A nested anonymous type definition.
- A reference to type definition that is followed by current type definition. These type references
will be deferred to later check if a type definition with that name exists in the schema.
Because the
SchemaSystemdoes not yet know the complete definition of these types, it cannot find them in theTypeStore. An instance ofPendingTypesis used to track information about types that we do not have a complete definition for yet. When theSchemaSystemfinishes loading these types, the type definitions inPendingTypescan be promoted theTypeStore.
Deferred type definition:
A deferred type definition is added to PendingTypes whenever encountered type reference whose definition
is outside the scope of current type definition that is being resolved.
e.g.
type:: {
name: foo,
type: bar,
}
type:: {
name: bar,
type: int
}
For above example, bar will be saved as deferred type definition until we resolve the definition of bar.
When the SchemaSystem finishes loading the type foo, the type definitions in
PendingTypes including deferred type definitions will be promoted to the TypeStore.
Once we resolve type definition for bar it will be updated in the TypeStore.
Implementations§
Source§impl PendingTypes
impl PendingTypes
Sourcepub fn update_type_store(
&mut self,
type_store: &mut TypeStore,
load_isl_import: Option<&IslImport>,
isl_type_names: &HashSet<&str>,
) -> IonSchemaResult<bool>
pub fn update_type_store( &mut self, type_store: &mut TypeStore, load_isl_import: Option<&IslImport>, isl_type_names: &HashSet<&str>, ) -> IonSchemaResult<bool>
Adds all the types from PendingTypes into given TypeStore including adding all the imported types into imports of TypeStore.
It also clears PendingTypes types for loading next set of types.
This method is used after a schema named type/root type is loaded entirely into PendingTypes
type_store- The TypeStore which will be updated with the types within this PendingTypeload_isl_import- If this argument is Some(isl_import), then we are not within an import process of schema. Based on given enum variant isl_import we will add the types to type_store. Otherwise we will add all the types from this PendingTypes to TypeStore.isl_type_names- The isl type names defined within the schema. This will be used to determine if a type definition actually exists within the schema. If a type definition from this list exists inPendingTypesit would have been added as a deferred type definition. This deferred type will be loaded intoTypeStoreas it is and will be replaced with a type definition once it is resolved. Returns true, if this update is not for an isl import type or it is for an isl import type but it is added to the type_store Otherwise, returns false if this update is for an isl import type and it is not yet added to the type_store.
Trait Implementations§
Source§impl Clone for PendingTypes
impl Clone for PendingTypes
Source§fn clone(&self) -> PendingTypes
fn clone(&self) -> PendingTypes
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more