use std::collections::HashMap; use serde::Deserialize; use serde_repr::Deserialize_repr; pub mod helpers; #[derive(Debug, Clone, Deserialize)] #[serde(tag = "action", rename_all = "lowercase")] pub enum NixBuildLogLine { Start(NixLogStartAction), Stop(NixLogStopAction), Result(NixLogResultAction), Msg(NixLogMsgAction), } impl NixBuildLogLine { pub fn id(&self) -> Option { match self { NixBuildLogLine::Start(NixLogStartAction { id, .. }) | NixBuildLogLine::Stop(NixLogStopAction { id }) | NixBuildLogLine::Result(NixLogResultAction { id, .. }) => Some(*id), NixBuildLogLine::Msg(..) => None, } } } /// What kind of activity was logged /// /// This definition mirrors the one in nixcpp. As it can evolve, the enum is marked as /// `non_exhaustive` and may get extended later on. #[derive(Debug, Clone, Copy, Deserialize_repr, PartialEq, Eq, Hash)] #[repr(u32)] #[non_exhaustive] pub enum ActivityKind { Unknown = 0, CopyPath = 100, FileTransfer = 101, Realise = 102, CopyPaths = 103, Builds = 104, Build = 105, OptimiseStore = 106, VerifyPaths = 107, Substitute = 108, QueryPathInfo = 109, PostBuildHook = 110, BuildWaiting = 111, FetchTree = 112, } /// What kind of result information was logged /// /// This definition mirrors the one in nixcpp. As it can evolve, the enum is marked as /// `non_exhaustive` and may get extended later on. #[derive(Debug, Clone, Copy, Deserialize_repr, PartialEq, Eq, Hash)] #[repr(u32)] #[non_exhaustive] pub enum ResultKind { FileLinked = 100, BuildLogLine = 101, UntrustedPath = 102, CorruptedPath = 103, SetPhase = 104, Progress = 105, SetExpected = 106, PostBuildLogLine = 107, FetchStatus = 108, } #[derive(Debug, Clone, Deserialize)] pub struct NixLogResultAction { pub id: u64, #[serde(rename = "type")] pub kind: ResultKind, #[serde(default)] pub fields: Vec, } #[derive(Debug, Clone, Deserialize)] pub struct NixLogStopAction { pub id: u64, } #[derive(Debug, Clone, Deserialize)] pub struct NixLogMsgAction { pub level: Option, pub msg: String, } #[derive(Debug, Clone, Deserialize)] pub struct NixLogStartAction { pub id: u64, pub level: i64, pub parent: i64, pub text: Option, #[serde(rename = "type")] pub kind: ActivityKind, #[serde(default)] pub fields: Vec, } #[derive(Debug, Clone, Deserialize)] pub struct RawNixDerivationInfoOutput(HashMap); impl RawNixDerivationInfoOutput { pub fn info(&self) -> &HashMap { &self.0 } } #[derive(Debug, Clone, Deserialize)] pub struct RawNixDerivationInfo { pub args: Vec, pub builder: String, #[serde(rename = "inputDrvs")] pub input_derivations: HashMap, #[serde(rename = "inputSrcs")] pub input_sources: Vec, pub name: String, pub outputs: HashMap>, pub system: String, }