Trait gpui2::Context

source ·
pub trait Context {
    type Result<T>;

    // Required methods
    fn build_model<T: 'static>(
        &mut self,
        build_model: impl FnOnce(&mut ModelContext<'_, T>) -> T
    ) -> Self::Result<Model<T>>;
    fn update_model<T, R>(
        &mut self,
        handle: &Model<T>,
        update: impl FnOnce(&mut T, &mut ModelContext<'_, T>) -> R
    ) -> Self::Result<R>
       where T: 'static;
    fn read_model<T, R>(
        &self,
        handle: &Model<T>,
        read: impl FnOnce(&T, &AppContext) -> R
    ) -> Self::Result<R>
       where T: 'static;
    fn update_window<T, F>(
        &mut self,
        window: AnyWindowHandle,
        f: F
    ) -> Result<T>
       where F: FnOnce(AnyView, &mut WindowContext<'_>) -> T;
    fn read_window<T, R>(
        &self,
        window: &WindowHandle<T>,
        read: impl FnOnce(View<T>, &AppContext) -> R
    ) -> Result<R>
       where T: 'static;
}

Required Associated Types§

source

type Result<T>

Required Methods§

source

fn build_model<T: 'static>( &mut self, build_model: impl FnOnce(&mut ModelContext<'_, T>) -> T ) -> Self::Result<Model<T>>

source

fn update_model<T, R>( &mut self, handle: &Model<T>, update: impl FnOnce(&mut T, &mut ModelContext<'_, T>) -> R ) -> Self::Result<R>where T: 'static,

source

fn read_model<T, R>( &self, handle: &Model<T>, read: impl FnOnce(&T, &AppContext) -> R ) -> Self::Result<R>where T: 'static,

source

fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Result<T>where F: FnOnce(AnyView, &mut WindowContext<'_>) -> T,

source

fn read_window<T, R>( &self, window: &WindowHandle<T>, read: impl FnOnce(View<T>, &AppContext) -> R ) -> Result<R>where T: 'static,

Implementors§

source§

impl Context for AppContext

§

type Result<T> = T

source§

impl Context for AsyncAppContext

§

type Result<T> = Result<T, Error>

source§

impl Context for AsyncWindowContext

§

type Result<T> = Result<T, Error>

source§

impl Context for WindowContext<'_>

§

type Result<T> = T

source§

impl<'a, T> Context for ModelContext<'a, T>

§

type Result<U> = U

source§

impl<V> Context for ViewContext<'_, V>

§

type Result<U> = U