pub struct Application { /* private fields */ }Expand description
极简跨平台桌面应用启动构建器(由 application 创建,参照 gpui-kit)。
Implementations§
Source§impl Application
impl Application
Sourcepub fn new() -> Self
pub fn new() -> Self
创建一个使用内置零依赖 NativeStdScheduler 与默认暗色主题的 Application 构建器。
Sourcepub fn with_scheduler(self, scheduler: Arc<dyn SchedulerBackend>) -> Self
pub fn with_scheduler(self, scheduler: Arc<dyn SchedulerBackend>) -> Self
注入自定义可插拔异步调度器后端(如 velox-async 的 TokioScheduler::global() 或 SmolScheduler::global())。
Sourcepub const fn with_theme(self, theme: CoreTheme) -> Self
pub const fn with_theme(self, theme: CoreTheme) -> Self
配置应用级默认主题。
Sourcepub const fn with_locale(self, locale: Locale) -> Self
pub const fn with_locale(self, locale: Locale) -> Self
配置应用级默认语言区域。
Sourcepub const fn with_i18n_catalog(self, catalog: &'static StaticCatalog) -> Self
pub const fn with_i18n_catalog(self, catalog: &'static StaticCatalog) -> Self
注册应用级静态多语言翻译目录。
Sourcepub fn with_dynamic_catalog(self, catalog: Arc<DynamicCatalog>) -> Self
pub fn with_dynamic_catalog(self, catalog: Arc<DynamicCatalog>) -> Self
注册应用级动态多语言翻译目录。
Sourcepub const fn with_backend(self, backend: DesktopRenderBackend) -> Self
pub const fn with_backend(self, backend: DesktopRenderBackend) -> Self
配置应用级默认桌面渲染后端(GPU / Software)。
Sourcepub const fn with_dpi_scale(self, scale: usize) -> Self
pub const fn with_dpi_scale(self, scale: usize) -> Self
显式锁定 HiDPI 缩放倍率。
Sourcepub fn build_headless(
self,
setup: impl FnOnce(&mut AppContext),
) -> Option<BuiltWindow>
pub fn build_headless( self, setup: impl FnOnce(&mut AppContext), ) -> Option<BuiltWindow>
以无头模式执行应用初始化回调并返回已配置好的 BuiltWindow(不弹出真实窗口,专供测试、CI 与 --headless)。
Sourcepub fn run(self, setup: impl FnOnce(&mut AppContext))
pub fn run(self, setup: impl FnOnce(&mut AppContext))
启动桌面应用主事件循环:执行 setup 打开窗口并自动接管原生 winit 事件循环。
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Application
impl !UnwindSafe for Application
impl Forget for Application
impl Freeze for Applicationwhere
*const ArcInner<dyn SchedulerBackend> is !null: Freeze,
PhantomData<ArcInner<dyn SchedulerBackend>>: Freeze,
&'static StaticCatalog: Freeze,
*const ArcInner<DynamicCatalog> is !null: Freeze,
PhantomData<ArcInner<DynamicCatalog>>: Freeze,
impl Move for Application
impl Send for Application
impl Sync for Application
impl Unpin for Application
impl UnsafeUnpin for Applicationwhere
*const ArcInner<dyn SchedulerBackend> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn SchedulerBackend>>: UnsafeUnpin,
&'static StaticCatalog: UnsafeUnpin,
*const ArcInner<DynamicCatalog> is !null: UnsafeUnpin,
PhantomData<ArcInner<DynamicCatalog>>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FluentBuilder for T
impl<T> FluentBuilder for T
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
当
condition 为 true 时执行闭包修饰自身,否则原样返回。Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Self
fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self
根据
condition 在两个修饰分支之间二选一。Source§fn when_some<O>(
self,
option: Option<O>,
then: impl FnOnce(Self, O) -> Self,
) -> Self
fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self
当
option 为 Some(value) 时执行闭包修饰自身,否则原样返回。