pub struct ComponentMeta {
pub type_id: fn() -> TypeId,
pub name: &'static str,
pub dep_type_ids: &'static [fn() -> TypeId],
pub factory: fn(&Store) -> Box<dyn Any + Send + Sync>,
pub scope: Scope,
pub impl_traits: &'static [fn() -> TypeId],
pub trait_impls: &'static [TraitImplEntry],
pub init_sort_fn: fn() -> i32,
pub init_fn: fn(&Arc<App>) -> RIE<()>,
pub async_init_fn: fn(&Arc<App>) -> BoxFuture<RIE<()>>,
pub async_run_fn: fn(&Arc<App>, CancellationToken) -> BoxFuture<RIE<()>>,
pub shutdown_fn: fn(&Store),
}Expand description
组件注册元数据(linkme 收集用)
核心字段 + 生命周期函数指针。
函数指针由宏生成,内部调用 <T as Component>::xxx(),
解决 ComponentMeta 类型擦除后无法调用 trait 方法的问题。
Fields§
§type_id: fn() -> TypeId返回组件类型 TypeId
name: &'static str组件类型名(调试用)
dep_type_ids: &'static [fn() -> TypeId]依赖类型 ID 列表(用于拓扑排序)
factory: fn(&Store) -> Box<dyn Any + Send + Sync>工厂函数:从 Store 构建组件,返回类型擦除的 Box
scope: Scope作用域
impl_traits: &'static [fn() -> TypeId]该组件实现的 trait TypeId 列表
trait_impls: &'static [TraitImplEntry]trait 实现条目列表(用于填充 TRAIT_IMPL_MAP)
init_sort_fn: fn() -> i32初始化排序值(值越小越先执行)
init_fn: fn(&Arc<App>) -> RIE<()>同步初始化(App 阶段)
async_init_fn: fn(&Arc<App>) -> BoxFuture<RIE<()>>异步初始化(App 阶段)
async_run_fn: fn(&Arc<App>, CancellationToken) -> BoxFuture<RIE<()>>异步运行(后台 task)
shutdown_fn: fn(&Store)优雅关闭
Implementations§
Auto Trait Implementations§
impl Freeze for ComponentMeta
impl RefUnwindSafe for ComponentMeta
impl Send for ComponentMeta
impl Sync for ComponentMeta
impl Unpin for ComponentMeta
impl UnsafeUnpin for ComponentMeta
impl UnwindSafe for ComponentMeta
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