File: mod.rs

package info (click to toggle)
rust-abscissa-core 0.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 420 kB
  • sloc: makefile: 4
file content (59 lines) | stat: -rw-r--r-- 1,602 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Example application used for testing purposes
#![cfg(feature = "default")]
use abscissa_core::{
    application, clap::Parser, config, Application, Command, Configurable, FrameworkError,
    Runnable, StandardPaths,
};
use serde::{Deserialize, Serialize};
use std::path::PathBuf;

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct ExampleConfig {}

#[derive(Command, Debug, Parser)]
pub struct ExampleCommand {}

impl Configurable<ExampleConfig> for ExampleCommand {
    fn config_path(&self) -> Option<PathBuf> {
        None
    }
}

impl Runnable for ExampleCommand {
    fn run(&self) {
        unimplemented!();
    }
}

#[derive(Debug, Default)]
pub struct ExampleApp {
    config: Option<ExampleConfig>,
    state: application::State<Self>,
}

impl Application for ExampleApp {
    type Cmd = ExampleCommand;
    type Cfg = ExampleConfig;
    type Paths = StandardPaths;

    fn config(&self) -> config::Reader<ExampleConfig> {
        unimplemented!();
    }

    fn state(&self) -> &application::State<Self> {
        unimplemented!();
    }

    fn register_components(&mut self, command: &Self::Cmd) -> Result<(), FrameworkError> {
        let framework_components = self.framework_components(command)?;
        let mut app_components = self.state.components_mut();
        app_components.register(framework_components)
    }

    fn after_config(&mut self, config: Self::Cfg) -> Result<(), FrameworkError> {
        let mut components = self.state.components_mut();
        components.after_config(&config)?;
        self.config = Some(config);
        Ok(())
    }
}