Trait Application

Source
pub trait Application: Sized {
    type Err: Send + 'static;
    type Config: Config;
    type Options: Options;

    // Required methods
    fn new(_: Self::Options, _: Self::Config) -> Result<Self, Self::Err>;
    fn run_once(&mut self, context: &Context) -> Result<Stopping, Self::Err>;

    // Provided methods
    fn signals() -> &'static [Signal] { ... }
    fn received_signal(&mut self, _: Signal) { ... }
    fn shutdown(self) -> Result<(), Self::Err> { ... }
}
Expand description

The application; domain-specific program logic

Required Associated Types§

Source

type Err: Send + 'static

Main error export of the Application

Source

type Config: Config

Config to be loaded from a file

Source

type Options: Options

Options from the command line

Required Methods§

Source

fn new(_: Self::Options, _: Self::Config) -> Result<Self, Self::Err>

Create a new instance given the options and config

Source

fn run_once(&mut self, context: &Context) -> Result<Stopping, Self::Err>

Called repeatedly in the main loop of the application.

Provided Methods§

Source

fn signals() -> &'static [Signal]

Which signal the application is interested in receiving.

By default, only INT and TERM are blocked and handled.

Source

fn received_signal(&mut self, _: Signal)

Handle a received signal

Source

fn shutdown(self) -> Result<(), Self::Err>

Called when the application is shutting down

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§