haz_domain/settings/output.rs
1//! Output-mode workspace settings.
2//!
3//! Carries the executor's choice between live-streamed and
4//! buffered task output (`EXEC-016`).
5
6/// How the executor surfaces a running task's `stdout` and
7/// `stderr` to the user.
8///
9/// `Default::default()` returns [`OutputMode::Live`], matching the
10/// `CFG-030` default.
11///
12/// # Examples
13///
14/// ```
15/// use haz_domain::settings::output::OutputMode;
16///
17/// assert_eq!(OutputMode::default(), OutputMode::Live);
18/// assert_ne!(OutputMode::Live, OutputMode::Buffered);
19/// ```
20#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
21pub enum OutputMode {
22 /// Stream stdout/stderr interleaved as they are produced
23 /// (default).
24 #[default]
25 Live,
26 /// Buffer stdout/stderr until the task terminates, then emit
27 /// the buffered streams as a single block per task.
28 Buffered,
29}
30
31/// Workspace-wide output settings.
32///
33/// `Default::default()` yields the `CFG-030` default
34/// ([`OutputMode::Live`]); an absent `output` mapping in
35/// `workspace.yml` is equivalent to this default.
36///
37/// # Examples
38///
39/// ```
40/// use haz_domain::settings::output::{OutputMode, OutputSettings};
41///
42/// let os = OutputSettings::default();
43/// assert_eq!(os.mode, OutputMode::Live);
44/// ```
45#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
46pub struct OutputSettings {
47 /// How task output is surfaced (`EXEC-016`).
48 pub mode: OutputMode,
49}
50
51#[cfg(test)]
52mod tests {
53 use crate::settings::output::{OutputMode, OutputSettings};
54
55 #[test]
56 fn output_mode_default_is_live() {
57 assert_eq!(OutputMode::default(), OutputMode::Live);
58 }
59
60 #[test]
61 fn output_mode_variants_are_distinct() {
62 assert_ne!(OutputMode::Live, OutputMode::Buffered);
63 }
64
65 #[test]
66 fn output_settings_default_is_live() {
67 assert_eq!(OutputSettings::default().mode, OutputMode::Live);
68 }
69
70 #[test]
71 fn output_settings_carry_chosen_mode() {
72 let os = OutputSettings {
73 mode: OutputMode::Buffered,
74 };
75 assert_eq!(os.mode, OutputMode::Buffered);
76 }
77}