nanite_docker/instruction/stopsignal.rs
1use alloc::string::String;
2use core::fmt::{Display, Formatter};
3
4/// Represents a `STOPSIGNAL` instruction.
5/// ```rust
6/// use nanite_docker::{StopSignal, Instruction};
7///
8/// let stop_signal = StopSignal::ByName("SIGTERM".into());
9/// let stop_signal_built = format!("{stop_signal}");
10/// assert_eq!(stop_signal_built, r#"STOPSIGNAL SIGTERM"#);
11///
12/// let stop_signal = StopSignal::ById(15);
13/// let stop_signal_built = format!("{stop_signal}");
14/// assert_eq!(stop_signal_built, r#"STOPSIGNAL 15"#);
15/// ```
16#[derive(Clone, Debug)]
17pub enum StopSignal {
18 ByName(String),
19 ById(usize),
20}
21impl Display for StopSignal {
22 fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
23 match self {
24 Self::ByName(n) => write!(f, "STOPSIGNAL {n}"),
25 Self::ById(i) => write!(f, "STOPSIGNAL {i}"),
26 }
27 }
28}