pub struct AppContext { /* private fields */ }Expand description
应用级启动上下文(传入 Application::run 回调,参照 gpui-kit |cx| { init(cx); open_window(..., cx, ...); })。
Implementations§
Source§impl AppContext
impl AppContext
Sourcepub fn set_scheduler(&mut self, scheduler: Arc<dyn SchedulerBackend>)
pub fn set_scheduler(&mut self, scheduler: Arc<dyn SchedulerBackend>)
设置全局默认异步调度器后端(后续打开的窗口将自动继承)。
Sourcepub fn scheduler_name(&self) -> &'static str
pub fn scheduler_name(&self) -> &'static str
返回当前应用配置的异步调度器名称。
Sourcepub fn set_locale(&mut self, locale: Locale)
pub fn set_locale(&mut self, locale: Locale)
设置全局默认语言区域。
Sourcepub fn set_i18n_catalog(&mut self, catalog: &'static StaticCatalog)
pub fn set_i18n_catalog(&mut self, catalog: &'static StaticCatalog)
注册全局静态多语言翻译词典。
Sourcepub fn set_dynamic_catalog(&mut self, catalog: Arc<DynamicCatalog>)
pub fn set_dynamic_catalog(&mut self, catalog: Arc<DynamicCatalog>)
注册全局动态多语言翻译词典。
Sourcepub fn set_backend(&mut self, backend: DesktopRenderBackend)
pub fn set_backend(&mut self, backend: DesktopRenderBackend)
设置默认桌面渲染后端。
Sourcepub fn open_window<V: View>(
&mut self,
options: WindowOptions,
build_root: impl FnOnce(&mut WindowContext<'_>) -> Handle<V>,
) -> Result<WindowHandle<V>, AppError>
pub fn open_window<V: View>( &mut self, options: WindowOptions, build_root: impl FnOnce(&mut WindowContext<'_>) -> Handle<V>, ) -> Result<WindowHandle<V>, AppError>
打开主桌面窗口并挂载根视图。
Auto Trait Implementations§
impl !Freeze for AppContext
impl !RefUnwindSafe for AppContext
impl !Send for AppContext
impl !Sync for AppContext
impl !UnwindSafe for AppContext
impl Forget for AppContext
impl Move for AppContext
impl Unpin for AppContext
impl UnsafeUnpin for AppContext
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) 时执行闭包修饰自身,否则原样返回。