pub struct App<T: Subcommand + Clone + 'static = EmptyCommand> { /* private fields */ }Expand description
应用核心结构
Implementations§
Source§impl<T: Subcommand + Clone + 'static> App<T>
impl<T: Subcommand + Clone + 'static> App<T>
Sourcepub fn register_command_handler<F, Fut>(&self, handler: F) -> &Selfwhere
F: Fn(T, Arc<ApplicationInner>, Arc<ComponentFactoryManager>) -> (InitStrategy, Fut) + Send + Sync + 'static,
Fut: Future<Output = Result<()>> + Send + 'static,
pub fn register_command_handler<F, Fut>(&self, handler: F) -> &Selfwhere
F: Fn(T, Arc<ApplicationInner>, Arc<ComponentFactoryManager>) -> (InitStrategy, Fut) + Send + Sync + 'static,
Fut: Future<Output = Result<()>> + Send + 'static,
注册命令处理器
Sourcepub fn register_component_factory<Comp, F, Fut>(
&self,
label: Option<String>,
factory: F,
) -> &Selfwhere
Comp: DynComponent + 'static,
F: Fn(Arc<ApplicationInner>, String) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Comp>> + Send + 'static,
pub fn register_component_factory<Comp, F, Fut>(
&self,
label: Option<String>,
factory: F,
) -> &Selfwhere
Comp: DynComponent + 'static,
F: Fn(Arc<ApplicationInner>, String) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Comp>> + Send + 'static,
注册组件工厂
Sourcepub fn set_default_handler<F, Fut>(&self, handler: F) -> &Selfwhere
F: Fn(Arc<ApplicationInner>, Arc<ComponentFactoryManager>) -> (InitStrategy, Fut) + Send + Sync + 'static,
Fut: Future<Output = Result<()>> + Send + 'static,
pub fn set_default_handler<F, Fut>(&self, handler: F) -> &Selfwhere
F: Fn(Arc<ApplicationInner>, Arc<ComponentFactoryManager>) -> (InitStrategy, Fut) + Send + Sync + 'static,
Fut: Future<Output = Result<()>> + Send + 'static,
设置默认处理器
Sourcepub fn set_wait_signal(&self, wait: bool) -> &Self
pub fn set_wait_signal(&self, wait: bool) -> &Self
设置是否等待关闭信号
Sourcepub async fn get_all_component_keys(&self) -> Vec<ComponentKey>
pub async fn get_all_component_keys(&self) -> Vec<ComponentKey>
获取所有已初始化组件的键
Source§impl App<EmptyCommand>
impl App<EmptyCommand>
Sourcepub fn with_empty_command() -> Self
pub fn with_empty_command() -> Self
创建带有空命令的应用实例
Trait Implementations§
Auto Trait Implementations§
impl<T = EmptyCommand> !Freeze for App<T>
impl<T = EmptyCommand> !RefUnwindSafe for App<T>
impl<T = EmptyCommand> !UnwindSafe for App<T>
impl<T> Send for App<T>where
T: Send,
impl<T> Sync for App<T>where
T: Sync,
impl<T> Unpin for App<T>where
T: Unpin,
impl<T> UnsafeUnpin for App<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