Struct uniffi_bindgen::interface::universe::TypeUniverse
source · pub(crate) struct TypeUniverse {
pub namespace: NamespaceMetadata,
pub namespace_docstring: Option<String>,
type_definitions: HashMap<String, Type>,
all_known_types: BTreeSet<Type>,
}
Expand description
The set of all possible types used in a particular component interface.
Every component API uses a finite number of types, including primitive types, API-defined types like records and enums, and recursive types such as sequences of the above. Our component API doesn’t support fancy generics so this is a finitely-enumerable set, which is useful to be able to operate on explicitly.
You could imagine this struct doing some clever interning of names and so-on in future, to reduce the overhead of passing around Type instances. For now we just do a whole lot of cloning.
Fields§
§namespace: NamespaceMetadata
The unique prefixes that we’ll use for namespacing when exposing this component’s API.
namespace_docstring: Option<String>
§type_definitions: HashMap<String, Type>
§all_known_types: BTreeSet<Type>
Implementations§
source§impl TypeUniverse
impl TypeUniverse
pub fn new(namespace: NamespaceMetadata) -> Self
sourcefn add_type_definition(&mut self, name: &str, type_: &Type) -> Result<()>
fn add_type_definition(&mut self, name: &str, type_: &Type) -> Result<()>
Add the definition of a named Type.
sourcepub(super) fn get_type_definition(&self, name: &str) -> Option<Type>
pub(super) fn get_type_definition(&self, name: &str) -> Option<Type>
Get the Type corresponding to a given name, if any.
sourcepub fn add_known_type(&mut self, type_: &Type) -> Result<()>
pub fn add_known_type(&mut self, type_: &Type) -> Result<()>
Add a Type to the set of all types seen in the component interface.
sourcepub fn add_known_types(&mut self, types: TypeIterator<'_>) -> Result<()>
pub fn add_known_types(&mut self, types: TypeIterator<'_>) -> Result<()>
Add many Type
s…
sourcepub fn iter_known_types(&self) -> impl Iterator<Item = &Type>
pub fn iter_known_types(&self) -> impl Iterator<Item = &Type>
Iterator over all the known types in this universe.