[][src]Trait zebrad::prelude::Application

pub trait Application: 'static + Default {
    type Cmd: Command + Configurable<Self::Cfg>;
    type Cfg: Config;
    type Paths: ExePath + RootPath + Default;
    fn config(&self) -> &Self::Cfg;
fn state(&self) -> &State<Self>;
fn state_mut(&mut self) -> &mut State<Self>;
fn register_components(
        &mut self,
        command: &Self::Cmd
    ) -> Result<(), FrameworkError>;
fn after_config(
        &mut self,
        config: Self::Cfg,
        command: &Self::Cmd
    ) -> Result<(), FrameworkError>; fn run<I>(app_cell: &'static Cell<Lock<Self>>, args: I)
    where
        I: IntoIterator<Item = String>
, { ... }
fn init(&mut self, command: &Self::Cmd) -> Result<(), FrameworkError> { ... }
fn framework_components(
        &mut self,
        command: &Self::Cmd
    ) -> Result<Vec<Box<dyn Component<Self> + 'static>>, FrameworkError> { ... }
fn load_config(&mut self, path: &Path) -> Result<Self::Cfg, FrameworkError> { ... }
fn name(&self) -> &'static str { ... }
fn description(&self) -> &'static str { ... }
fn version(&self) -> Version { ... }
fn authors(&self) -> Vec<String> { ... }
fn term_colors(&self, command: &Self::Cmd) -> ColorChoice { ... }
fn tracing_config(&self, command: &Self::Cmd) -> Config { ... }
fn handle_signal(&mut self, signal: Signal) -> Result<(), FrameworkError> { ... }
fn shutdown(&mut self, shutdown: Shutdown) -> ! { ... } }

Commonly used Abscissa traits Application types implementing this trait own global application state, including configuration and arbitrary other values stored within application components.

Application lifecycle is handled by a set of components owned by types implementing this trait. It also ties together the following:

Associated Types

type Cmd: Command + Configurable<Self::Cfg>

Application (sub)command which serves as the main entry point.

type Cfg: Config

Configuration type used by this application.

type Paths: ExePath + RootPath + Default

Paths to application resources,

Loading content...

Required methods

fn config(&self) -> &Self::Cfg

Accessor for application configuration.

fn state(&self) -> &State<Self>

Borrow the application state immutably.

fn state_mut(&mut self) -> &mut State<Self>

Borrow the application state mutably.

fn register_components(
    &mut self,
    command: &Self::Cmd
) -> Result<(), FrameworkError>

Register all components used by this application

fn after_config(
    &mut self,
    config: Self::Cfg,
    command: &Self::Cmd
) -> Result<(), FrameworkError>

Post-configuration lifecycle callback.

Called regardless of whether config is loaded to indicate this is the time in app lifecycle when configuration would be loaded if possible.

This method is responsible for invoking the after_config handlers on all components in the registry. This is presently done in the standard application template, but is not otherwise handled directly by the framework (as ownership precludes it).

Loading content...

Provided methods

fn run<I>(app_cell: &'static Cell<Lock<Self>>, args: I) where
    I: IntoIterator<Item = String>, 

Run application with the given command-line arguments and running the appropriate Command type.

fn init(&mut self, command: &Self::Cmd) -> Result<(), FrameworkError>

Load this application's configuration and initialize its components.

fn framework_components(
    &mut self,
    command: &Self::Cmd
) -> Result<Vec<Box<dyn Component<Self> + 'static>>, FrameworkError>

Initialize the framework's default set of components, potentially sourcing terminal and tracing options from command line arguments.

fn load_config(&mut self, path: &Path) -> Result<Self::Cfg, FrameworkError>

Load configuration from the given path.

Returns an error if the configuration could not be loaded.

fn name(&self) -> &'static str

Name of this application as a string.

fn description(&self) -> &'static str

Description of this application.

fn version(&self) -> Version

Version of this application.

fn authors(&self) -> Vec<String>

Authors of this application.

fn term_colors(&self, command: &Self::Cmd) -> ColorChoice

Color configuration for this application.

fn tracing_config(&self, command: &Self::Cmd) -> Config

Get the tracing configuration for this application.

fn handle_signal(&mut self, signal: Signal) -> Result<(), FrameworkError>

Handle a Unix signal received by this application

fn shutdown(&mut self, shutdown: Shutdown) -> !

Shut down this application gracefully, exiting with success.

Loading content...

Implementors

impl Application for ZebradApp[src]

type Cmd = EntryPoint<ZebradCmd>

Entrypoint command for this application.

type Cfg = ZebradConfig

Application configuration.

type Paths = StandardPaths

Paths to resources within the application.

fn config(&self) -> &ZebradConfig[src]

Accessor for application configuration.

fn state(&self) -> &State<Self>[src]

Borrow the application state immutably.

fn state_mut(&mut self) -> &mut State<Self>[src]

Borrow the application state mutably.

fn register_components(
    &mut self,
    command: &Self::Cmd
) -> Result<(), FrameworkError>
[src]

Register all components used by this application.

If you would like to add additional components to your application beyond the default ones provided by the framework, this is the place to do so.

fn after_config(
    &mut self,
    config: Self::Cfg,
    command: &Self::Cmd
) -> Result<(), FrameworkError>
[src]

Post-configuration lifecycle callback.

Called regardless of whether config is loaded to indicate this is the time in app lifecycle when configuration would be loaded if possible.

Loading content...