nanite_docker/instruction/
expose.rs1use core::fmt::{Display, Formatter};
2
3#[derive(Clone, Debug)]
15pub struct Expose {
16 pub port: u16,
17 pub protocol: Option<ExposeProtocol>,
18}
19
20impl Display for Expose {
21 fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
22 match &self.protocol {
23 Some(p) => match p {
24 ExposeProtocol::tcp => write!(f, "EXPOSE {}/tcp", self.port),
25 ExposeProtocol::udp => write!(f, "EXPOSE {}/udp", self.port),
26 },
27 None => write!(f, "EXPOSE {}", self.port),
28 }
29 }
30}
31
32#[allow(
34 nonstandard_style,
35 reason = "tcp and udp are standards that should be lowercase for legibility"
36)]
37#[derive(Clone, Debug)]
38pub enum ExposeProtocol {
39 tcp,
40 udp,
41}