diff --git a/cognos/src/lib.rs b/cognos/src/lib.rs index 11bac2b..a6443ca 100644 --- a/cognos/src/lib.rs +++ b/cognos/src/lib.rs @@ -11,16 +11,28 @@ pub use aterm::{ parse_drv_file, }; pub use internal_json::{Actions, Activities, Id, Verbosity}; -pub use state::{BuildInfo, BuildStatus, Dependencies, Derivation, Host, OutputName, State, ProgressState}; +pub use state::{ + BuildInfo, + BuildStatus, + Dependencies, + Derivation, + Host, + OutputName, + ProgressState, + State, +}; /// Process a list of actions and return the resulting state -#[must_use] pub fn process_actions(actions: Vec) -> State { +#[must_use] +pub fn process_actions(actions: Vec) -> State { let mut state = State { - progress: ProgressState::JustStarted, - derivations: HashMap::new(), - builds: HashMap::new(), - dependencies: Dependencies { deps: HashMap::new() }, - store_paths: HashMap::new(), + progress: ProgressState::JustStarted, + derivations: HashMap::new(), + builds: HashMap::new(), + dependencies: Dependencies { + deps: HashMap::new(), + }, + store_paths: HashMap::new(), dependency_states: HashMap::new(), }; for action in actions { diff --git a/cognos/src/state.rs b/cognos/src/state.rs index a4739c2..c72db70 100644 --- a/cognos/src/state.rs +++ b/cognos/src/state.rs @@ -97,18 +97,22 @@ pub struct Dependencies { // #[derive(Default)] pub struct State { - pub progress: ProgressState, - pub derivations: HashMap, - pub builds: HashMap, - pub dependencies: Dependencies, - pub store_paths: HashMap, + pub progress: ProgressState, + pub derivations: HashMap, + pub builds: HashMap, + pub dependencies: Dependencies, + pub store_paths: HashMap, pub dependency_states: HashMap, } impl State { pub fn imbibe(&mut self, action: Actions) { match action { - Actions::Start { id, activity: _activity, .. } => { + Actions::Start { + id, + activity: _activity, + .. + } => { let derivation = Derivation { store_path: PathBuf::from("/nix/store/placeholder"), }; @@ -118,11 +122,11 @@ impl State { let _path = &self.derivations.get(&id).unwrap().store_path; let build_info = BuildInfo { - start: 0.0, // Placeholder, would need actual time - host: Host::Localhost, // Placeholder - estimate: None, + start: 0.0, // Placeholder, would need actual time + host: Host::Localhost, // Placeholder + estimate: None, activity_id: id, - state: BuildStatus::Running, + state: BuildStatus::Running, }; self.builds.insert(id, build_info.clone()); self.dependencies.deps.insert(id, build_info); @@ -152,4 +156,4 @@ impl State { }, } } -} \ No newline at end of file +}