Skip to main content

AppContext

Struct AppContext 

Source
pub struct AppContext { /* private fields */ }
Expand description

应用级启动上下文(传入 Application::run 回调,参照 gpui-kit |cx| { init(cx); open_window(..., cx, ...); })。

Implementations§

Source§

impl AppContext

Source

pub fn set_scheduler(&mut self, scheduler: Arc<dyn SchedulerBackend>)

设置全局默认异步调度器后端(后续打开的窗口将自动继承)。

Source

pub fn scheduler_name(&self) -> &'static str

返回当前应用配置的异步调度器名称。

Source

pub fn set_theme(&mut self, theme: CoreTheme)

设置全局默认主题。

Source

pub fn set_locale(&mut self, locale: Locale)

设置全局默认语言区域。

Source

pub fn set_i18n_catalog(&mut self, catalog: &'static StaticCatalog)

注册全局静态多语言翻译词典。

Source

pub fn set_dynamic_catalog(&mut self, catalog: Arc<DynamicCatalog>)

注册全局动态多语言翻译词典。

Source

pub fn set_backend(&mut self, backend: DesktopRenderBackend)

设置默认桌面渲染后端。

Source

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
where Arc<dyn SchedulerBackend>: Unpin, &'static StaticCatalog: Unpin, Arc<DynamicCatalog>: Unpin, *const u8 is !null: Unpin, &'static PodVTable: Unpin, *const Element<'static>: Unpin, *mut u8: Unpin, *mut (): Unpin, *const ChunkFooter is !null: Unpin, *const CoreTheme: Unpin, *const PodPool: Unpin, Arc<ForegroundShared>: Unpin, Rc<RefCell<ForegroundLocal>>: Unpin, &'static str: Unpin, &'static [u8]: Unpin, &'static dyn Fn(&mut dyn SurfacePainter): Unpin, &'static StyledQuad<'static>: Unpin, &'static LayerSpec<'static>: Unpin, &'static ExternalTextureSpec: Unpin, &'static RichTextSpec<'static>: Unpin, &'static DecodedImageSpec: Unpin, &'static VectorDrawSpec<'static>: Unpin, &'static SceneCanvasSpec<'static>: Unpin, &'static DivInteractivity<'static>: Unpin, *const DrawOp<'static>: Unpin, *const HitRegion<'static>: Unpin, *mut LayoutNode<'static, 'static>: Unpin,

§

impl UnsafeUnpin for AppContext

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> FluentBuilder for T

Source§

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

根据 condition 在两个修饰分支之间二选一。
Source§

fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self

当 option 为 Some(value) 时执行闭包修饰自身,否则原样返回。
Source§

fn when_none<O>( self, option: &Option<O>, then: impl FnOnce(Self) -> Self, ) -> Self

当 option 为 None 时执行闭包修饰自身,否则原样返回。
Source§

fn apply<U>(self, f: impl FnOnce(Self) -> U) -> U

通用管道映射变换(避免与 Iterator::map / Option::map 重名)。
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.