pub struct Registry { /* private fields */ }Expand description
Runtime registry for querying type metadata.
The registry is loaded from a JSON sidecar file generated by the badeline-rustc compiler plugin.
Implementations§
Source§impl Registry
impl Registry
Sourcepub fn load<P: AsRef<Path>>(path: P) -> Result<Self, Box<dyn Error>>
pub fn load<P: AsRef<Path>>(path: P) -> Result<Self, Box<dyn Error>>
Load the registry from a JSON file.
Sourcepub fn register<T: 'static>(&mut self, type_name: &str)
pub fn register<T: 'static>(&mut self, type_name: &str)
Register a type for TypeId-based lookup.
Call this for each type you want to query by TypeId. The type name should match the name in the registry.
Sourcepub fn get<T: 'static>(&self) -> Option<&TypeInfo>
pub fn get<T: 'static>(&self) -> Option<&TypeInfo>
Get type info by TypeId.
The type must have been registered with register first.
Sourcepub fn get_by_name(&self, name: &str) -> Option<&TypeInfo>
pub fn get_by_name(&self, name: &str) -> Option<&TypeInfo>
Get type info by name.
Sourcepub fn type_names(&self) -> impl Iterator<Item = &str>
pub fn type_names(&self) -> impl Iterator<Item = &str>
List all known type names.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Registry
impl RefUnwindSafe for Registry
impl Send for Registry
impl Sync for Registry
impl Unpin for Registry
impl UnsafeUnpin for Registry
impl UnwindSafe for Registry
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
Mutably borrows from an owned value. Read more