use core::fmt::{Display, Formatter};
#[derive(Clone, Debug)]
pub struct Expose {
pub port: u16,
pub protocol: Option<ExposeProtocol>,
}
impl Display for Expose {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
match &self.protocol {
Some(p) => match p {
ExposeProtocol::tcp => write!(f, "EXPOSE {}/tcp", self.port),
ExposeProtocol::udp => write!(f, "EXPOSE {}/udp", self.port),
},
None => write!(f, "EXPOSE {}", self.port),
}
}
}
#[allow(
nonstandard_style,
reason = "tcp and udp are standards that should be lowercase for legibility"
)]
#[derive(Clone, Debug)]
pub enum ExposeProtocol {
tcp,
udp,
}