pub struct Application(/* private fields */);Expand description
重导出 App 核心模块(App、Context、Entity、EntityId 等)
对 RGPUI 应用的引用,通常在应用的 main 函数中构建。
除初始配置和启动阶段外,你不会频繁与此类型交互。
Implementations§
Source§impl Application
表示尚未完全启动的应用。配置完成后,
使用 App::run 启动应用。
impl Application
表示尚未完全启动的应用。配置完成后,
使用 App::run 启动应用。
Sourcepub fn with_platform(platform: Rc<dyn Platform>) -> Self
pub fn with_platform(platform: Rc<dyn Platform>) -> Self
使用调用方提供的平台实现构建应用。
Sourcepub fn new_inaccessible(platform: Rc<dyn Platform>) -> Self
pub fn new_inaccessible(platform: Rc<dyn Platform>) -> Self
强制禁用无障碍(AccessKit)集成来构建应用。
在此模式下,无障碍 API(如 [div().role()][crate::StatefulInteractiveElement::role])
会静默地不执行任何操作。
参见无障碍指南了解被禁用功能的概述。
Sourcepub fn with_assets(self, asset_source: impl AssetSource) -> Self
pub fn with_assets(self, asset_source: impl AssetSource) -> Self
设置应用的资源来源。
Sourcepub fn with_http_client(self, http_client: Arc<dyn HttpClient>) -> Self
pub fn with_http_client(self, http_client: Arc<dyn HttpClient>) -> Self
设置应用的 HTTP 客户端。
Sourcepub fn with_quit_mode(self, mode: QuitMode) -> Self
pub fn with_quit_mode(self, mode: QuitMode) -> Self
配置应用自动退出的时机。
默认使用 QuitMode::Default。
Sourcepub fn run_embedded<F>(self, on_finish_launching: F) -> ApplicationHandle
pub fn run_embedded<F>(self, on_finish_launching: F) -> ApplicationHandle
为自行驱动运行循环的嵌入方启动应用。
在普通平台上,Platform::run 会在应用生命周期内阻塞,应用状态由
Application::run 的栈帧保持存活。嵌入平台(即运行循环归属他方,
例如编译为 Wasm guest 的 RGPUI,或托管在外部原生应用中的 RGPUI 视图)
实现 Platform::run 时会调用启动回调后立即返回。本方法支持这种模式:
它返回一个 ApplicationHandle 来保持应用存活,并允许嵌入方在外部运行
循环交还控制权时重新进入应用。
Sourcepub fn on_open_urls<F>(&self, callback: F) -> &Self
pub fn on_open_urls<F>(&self, callback: F) -> &Self
注册一个处理器,当平台指示应用打开一个或多个 URL 时被调用。
Sourcepub fn on_reopen<F>(&self, callback: F) -> &Self
pub fn on_reopen<F>(&self, callback: F) -> &Self
当已运行的应用再次被启动时调用处理器。 在 macOS 上,双击应用图标或通过 Dock 启动应用时会触发此回调。
Sourcepub fn on_system_wake<F>(&self, callback: F) -> &Self
pub fn on_system_wake<F>(&self, callback: F) -> &Self
当系统从休眠中唤醒时调用处理器。
Sourcepub fn background_executor(&self) -> BackgroundExecutor
pub fn background_executor(&self) -> BackgroundExecutor
返回与此应用关联的 BackgroundExecutor 句柄,可用于在后台生成 future。
Sourcepub fn foreground_executor(&self) -> ForegroundExecutor
pub fn foreground_executor(&self) -> ForegroundExecutor
返回与此应用关联的 ForegroundExecutor 句柄,可用于在前台生成 future。
Sourcepub fn text_system(&self) -> Arc<TextSystem> ⓘ
pub fn text_system(&self) -> Arc<TextSystem> ⓘ
返回与此应用关联的 TextSystem 引用。
Sourcepub fn path_for_auxiliary_executable(&self, name: &str) -> Result<PathBuf>
pub fn path_for_auxiliary_executable(&self, name: &str) -> Result<PathBuf>
返回应用 bundle 中指定名称的可执行文件的文件 URL
Auto Trait Implementations§
impl !RefUnwindSafe for Application
impl !Send for Application
impl !Sync for Application
impl !UnwindSafe for Application
impl Forget for Application
impl Freeze for Application
impl Move for Application
impl Unpin for Application
impl UnsafeUnpin for Application
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more