solana_test/
application.rs1use crate::{commands::EntryPoint, config::SolanaTestConfig};
4use abscissa_core::{
5 application::{self, AppCell},
6 config::{self, CfgCell},
7 trace, Application, FrameworkError, StandardPaths,
8};
9use abscissa_tokio::TokioComponent;
10
11pub static APP: AppCell<SolanaTestApp> = AppCell::new();
13
14#[derive(Debug)]
16pub struct SolanaTestApp {
17 config: CfgCell<SolanaTestConfig>,
19
20 state: application::State<Self>,
22}
23
24impl Default for SolanaTestApp {
29 fn default() -> Self {
30 Self {
31 config: CfgCell::default(),
32 state: application::State::default(),
33 }
34 }
35}
36
37impl Application for SolanaTestApp {
38 type Cmd = EntryPoint;
40
41 type Cfg = SolanaTestConfig;
43
44 type Paths = StandardPaths;
46
47 fn config(&self) -> config::Reader<SolanaTestConfig> {
49 self.config.read()
50 }
51
52 fn state(&self) -> &application::State<Self> {
54 &self.state
55 }
56
57 fn register_components(&mut self, command: &Self::Cmd) -> Result<(), FrameworkError> {
63 let mut framework_components = self.framework_components(command)?;
64 framework_components.push(Box::new(TokioComponent::new()?));
65 let mut app_components = self.state.components_mut();
66 app_components.register(framework_components)
67 }
68
69 fn after_config(&mut self, config: Self::Cfg) -> Result<(), FrameworkError> {
75 let mut components = self.state.components_mut();
77 components.after_config(&config)?;
78 self.config.set_once(config);
79 Ok(())
80 }
81
82 fn tracing_config(&self, command: &EntryPoint) -> trace::Config {
84 if command.verbose {
85 trace::Config::verbose()
86 } else {
87 trace::Config::default()
88 }
89 }
90}