Skip to main content

App

Trait App 

Source
pub trait App: 'static {
    type Spec: Spec;

    // Required methods
    fn overlay_model(
        &self,
        win: WindowId,
        id: <Self::Spec as Spec>::Overlay,
    ) -> OverlayModel;
    fn panel(&mut self, cx: &mut PanelCx<'_, Self::Spec>);
    fn overlay_body(&mut self, cx: &mut OverlayCx<'_, Self::Spec>);
    fn intent(
        &mut self,
        intent: Intent<Self::Spec>,
        cx: &mut IntentCx<'_, Self::Spec>,
    );

    // Provided methods
    fn init(&mut self, cx: &mut InitCx<'_, Self::Spec>) { ... }
    fn chrome_model(&self, win: WindowId) -> ChromeModel { ... }
    fn shutdown(&mut self) { ... }
}
Expand description

The application: view-model declarations, content hooks and the intent sink. One value drives any number of windows.

All hooks run on the runtime’s thread inside the tick (intent, shutdown) or the compose phase (chrome_model, overlay_model, panel, overlay_body). Business state stays behind the app’s own back-office handle; nothing back-office crosses into this crate (design §6.5).

Required Associated Types§

Source

type Spec: Spec

The app’s vocabulary (panels, overlays, actions).

Required Methods§

Source

fn overlay_model( &self, win: WindowId, id: <Self::Spec as Spec>::Overlay, ) -> OverlayModel

What the kernel draws around one open overlay’s body, declared per frame. The body itself is drawn by App::overlay_body.

Source

fn panel(&mut self, cx: &mut PanelCx<'_, Self::Spec>)

Draw one visible dock leaf’s content with library widget functions, once per frame per leaf. The kernel gives the content rect (inside the leaf’s frame and tab strip) and a scoped registration layer.

Source

fn overlay_body(&mut self, cx: &mut OverlayCx<'_, Self::Spec>)

Draw one open overlay’s body into the rect the frame leaves, once per frame per open overlay.

Source

fn intent( &mut self, intent: Intent<Self::Spec>, cx: &mut IntentCx<'_, Self::Spec>, )

One typed intent produced by the tick, in production order. Answer with visual effects via IntentCx::command; send business effects through the app’s own back-office handle.

Provided Methods§

Source

fn init(&mut self, cx: &mut InitCx<'_, Self::Spec>)

Startup: enqueue the initial windows, keymap bindings and default layout as commands. Runs once before the first tick.

Source

fn chrome_model(&self, win: WindowId) -> ChromeModel

What the kernel draws as this window’s chrome strip, declared per frame. Compose diffs it against the layout engine’s model and applies a SetChromeModel on change (the engine stays the single writer; hit-testing reads the same model the kernel draws).

Source

fn shutdown(&mut self)

The runtime is shutting down (last window closed or AppCommand::Shutdown).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§