pub struct FactoryRegistry<T>where
T: ?Sized + 'static,{ /* private fields */ }Expand description
工厂实现的注册表条目。
存储工厂的元数据,包括其 ID、产品类型 ID 和工厂实例。
此类型与 inventory crate 一起用于编译时注册。
Implementations§
Source§impl<T> FactoryRegistry<T>where
T: ?Sized + 'static,
impl<T> FactoryRegistry<T>where
T: ?Sized + 'static,
Sourcepub fn simple_factory() -> SimpleFactory<T>
pub fn simple_factory() -> SimpleFactory<T>
查找产品类型 T 的所有已注册工厂。
此函数扫描编译时工厂注册表,并返回一个 SimpleFactory 实例,
该实例包含一个从工厂 ID 到工厂实例的映射,这些工厂实例生产类型 T 的实例。
只包含为确切产品类型 T 注册的工厂。
§返回值
一个 SimpleFactory<T> 实例,包装一个 BTreeMap,其中:
- 键是工厂的静态字符串标识符
- 值是实现
Factory<T>的工厂实例的引用
Trait Implementations§
impl<T> Collect for FactoryRegistry<T>where
T: ?Sized + 'static,
Auto Trait Implementations§
impl<T> Freeze for FactoryRegistry<T>where
T: ?Sized,
impl<T> !RefUnwindSafe for FactoryRegistry<T>
impl<T> Send for FactoryRegistry<T>where
T: ?Sized,
impl<T> Sync for FactoryRegistry<T>where
T: ?Sized,
impl<T> Unpin for FactoryRegistry<T>where
T: ?Sized,
impl<T> UnsafeUnpin for FactoryRegistry<T>where
T: ?Sized,
impl<T> !UnwindSafe for FactoryRegistry<T>
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