Trait tmkms::prelude::Application [−][src]
pub trait Application: 'static + Default { type Cmd: Command + Configurable<Self::Cfg>; type Cfg: Config; type Paths: Default + ExePath + RootPath;}Show methods
pub fn config(&self) -> Arc<Self::Cfg>; pub fn state(&self) -> &State<Self>; pub fn register_components(
&mut self,
command: &Self::Cmd
) -> Result<(), FrameworkError>; pub fn after_config(
&mut self,
config: Self::Cfg
) -> Result<(), FrameworkError>; pub fn run<I>(app_cell: &'static AppCell<Self>, args: I)
where
I: IntoIterator<Item = String>, { ... } pub fn init(&mut self, command: &Self::Cmd) -> Result<(), FrameworkError> { ... } pub fn framework_components(
&mut self,
command: &Self::Cmd
) -> Result<Vec<Box<dyn Component<Self> + 'static, Global>, Global>, FrameworkError> { ... } pub fn load_config(
&mut self,
path: &Path
) -> Result<Self::Cfg, FrameworkError> { ... } pub fn name(&self) -> &'static str { ... } pub fn description(&self) -> &'static str { ... } pub fn version(&self) -> Version { ... } pub fn authors(&self) -> Vec<String, Global> { ... } pub fn term_colors(&self, command: &Self::Cmd) -> ColorChoice { ... } pub fn tracing_config(&self, command: &Self::Cmd) -> Config { ... } pub fn shutdown(&self, shutdown: Shutdown) -> ! { ... }
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:
Cmd
: application entrypointConfig
: application configurationPaths
: paths to various resources within the application
Associated Types
type Cmd: Command + Configurable<Self::Cfg>
[src]
Application (sub)command which serves as the main entry point.
type Cfg: Config
[src]
Configuration type used by this application.
type Paths: Default + ExePath + RootPath
[src]
Paths to application resources,
Required methods
pub fn config(&self) -> Arc<Self::Cfg>
[src]
Accessor for application configuration.
pub fn state(&self) -> &State<Self>
[src]
Borrow the application state.
pub fn register_components(
&mut self,
command: &Self::Cmd
) -> Result<(), FrameworkError>
[src]
&mut self,
command: &Self::Cmd
) -> Result<(), FrameworkError>
Register all components used by this application.
pub fn after_config(&mut self, config: Self::Cfg) -> 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.
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).
Provided methods
pub fn run<I>(app_cell: &'static AppCell<Self>, args: I) where
I: IntoIterator<Item = String>,
[src]
I: IntoIterator<Item = String>,
Run application with the given command-line arguments and running the
appropriate Command
type.
pub fn init(&mut self, command: &Self::Cmd) -> Result<(), FrameworkError>
[src]
Load this application’s configuration and initialize its components.
pub fn framework_components(
&mut self,
command: &Self::Cmd
) -> Result<Vec<Box<dyn Component<Self> + 'static, Global>, Global>, FrameworkError>
[src]
&mut self,
command: &Self::Cmd
) -> Result<Vec<Box<dyn Component<Self> + 'static, Global>, Global>, FrameworkError>
Initialize the framework’s default set of components, potentially sourcing terminal and tracing options from command line arguments.
pub fn load_config(&mut self, path: &Path) -> Result<Self::Cfg, FrameworkError>
[src]
Load configuration from the given path.
Returns an error if the configuration could not be loaded.
pub fn name(&self) -> &'static str
[src]
Name of this application as a string.
pub fn description(&self) -> &'static str
[src]
Description of this application.
pub fn version(&self) -> Version
[src]
Version of this application.
pub fn authors(&self) -> Vec<String, Global>
[src]
Authors of this application.
pub fn term_colors(&self, command: &Self::Cmd) -> ColorChoice
[src]
Color configuration for this application.
pub fn tracing_config(&self, command: &Self::Cmd) -> Config
[src]
Get the tracing configuration for this application.
pub fn shutdown(&self, shutdown: Shutdown) -> !
[src]
Shut down this application gracefully, exiting with success.
Implementors
impl Application for KmsApplication
[src]
type Cmd = KmsCommand
Entrypoint command for this application.
type Cfg = KmsConfig
Application configuration.
type Paths = StandardPaths
Paths to resources within the application.
fn config(&self) -> Reader<KmsConfig>
[src]
Accessor for application configuration.
fn state(&self) -> &State<Self>
[src]
Borrow the application state immutably.
fn register_components(
&mut self,
command: &Self::Cmd
) -> Result<(), FrameworkError>
[src]
&mut self,
command: &Self::Cmd
) -> Result<(), FrameworkError>
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) -> 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.
fn tracing_config(&self, command: &KmsCommand) -> Config
[src]
Get tracing configuration from command-line options