Skip to main content

App

Trait App 

Source
pub trait App {
    // Required method
    fn frame(&mut self, ui: &mut Ui);

    // Provided methods
    fn actions(&self) -> &'static [ActionSpec] { ... }
    fn action_revision(&self) -> Option<u64> { ... }
    fn action_available(&self, _spec: &ActionSpec) -> Result<(), ActionError> { ... }
    fn action(
        &mut self,
        _ui: &mut Ui,
        _spec: &ActionSpec,
        _input: &Value,
        _context: &ActionContext,
    ) -> Result<ActionResult, ActionError> { ... }
    fn action_inspect(&self, _query: &Value) -> Result<Value, ActionError> { ... }
    fn action_resource_info(&self, _uri: &str) -> Result<Resource, ActionError> { ... }
    fn action_resource_read(
        &self,
        _uri: &str,
        _offset: u64,
        _limit: usize,
    ) -> Result<Vec<u8>, ActionError> { ... }
    fn init(&mut self, _ui: &mut Ui) -> bool { ... }
    fn command(&mut self, _ui: &mut Ui, _id: u32, _arg: u32) -> bool { ... }
}
Expand description

the app’s callbacks (APP_DESC on_init, on_frame, on_command)

Required Methods§

Source

fn frame(&mut self, ui: &mut Ui)

builds the UI (every pass; no side effects except through widgets)

Provided Methods§

Source

fn actions(&self) -> &'static [ActionSpec]

Optional domain actions, in addition to the universal UI action catalogue.

Source

fn action_revision(&self) -> Option<u64>

Domain revision. None uses the UI runtime’s own: it moves with the controls (their set, labels, values and states, the focus, an open modal dialog, the title, enabled commands) and with every agent call that changes something, not with frames or the pointer, and it knows nothing of a change the user makes to the app’s data.

Source

fn action_available(&self, _spec: &ActionSpec) -> Result<(), ActionError>

Dynamic domain constraints such as read-only files or an absent selection.

Source

fn action( &mut self, _ui: &mut Ui, _spec: &ActionSpec, _input: &Value, _context: &ActionContext, ) -> Result<ActionResult, ActionError>

Domain action handler; adapters should call the same editing functions as the GUI.

Source

fn action_inspect(&self, _query: &Value) -> Result<Value, ActionError>

Filtered domain state; the default universal inspection includes the widget tree.

Source

fn action_resource_info(&self, _uri: &str) -> Result<Resource, ActionError>

Describe an application-owned binary resource returned by one of its actions.

Source

fn action_resource_read( &self, _uri: &str, _offset: u64, _limit: usize, ) -> Result<Vec<u8>, ActionError>

Read a bounded byte range of an application-owned resource, never an arbitrary path.

Source

fn init(&mut self, _ui: &mut Ui) -> bool

called before the first frame; false = initialisation failed (exit code 2)

Source

fn command(&mut self, _ui: &mut Ui, _id: u32, _arg: u32) -> bool

commands queued with ui.cmd_run and the built-in UIC_* ids; true = handled

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§