torrust_tracker_deployer_lib/presentation/cli/views/channel.rs
1//! Output channel routing for user-facing messages
2//!
3//! This module defines the channel enum that determines whether messages
4//! should be written to stdout or stderr.
5
6/// Output channel for routing messages
7///
8/// Determines whether a message should be written to stdout or stderr.
9/// Following Unix conventions:
10/// - **stdout**: Final results and structured data for piping/redirection
11/// - **stderr**: Progress updates, status messages, operational info, errors
12///
13/// # Examples
14///
15/// ```rust
16/// use torrust_tracker_deployer_lib::presentation::cli::views::Channel;
17///
18/// let channel = Channel::Stdout;
19/// assert_eq!(channel, Channel::Stdout);
20/// ```
21#[derive(Debug, Clone, Copy, PartialEq, Eq)]
22pub enum Channel {
23 /// Standard output stream for final results and data
24 Stdout,
25 /// Standard error stream for progress and operational messages
26 Stderr,
27}
28
29#[cfg(test)]
30mod tests {
31 use super::*;
32
33 #[test]
34 fn it_should_compare_equal_when_channels_are_same() {
35 assert_eq!(Channel::Stdout, Channel::Stdout);
36 assert_eq!(Channel::Stderr, Channel::Stderr);
37 }
38
39 #[test]
40 fn it_should_compare_not_equal_when_channels_are_different() {
41 assert_ne!(Channel::Stdout, Channel::Stderr);
42 }
43}