dcd 0.2.0

Docker Compose Deployment tool for remote servers
Documentation
mod ufw;
use std::fmt;

pub use ufw::UfwManager;

#[derive(Debug, Clone)]
pub struct PortConfig {
    pub port: u16,
    pub protocol: Protocol,
    pub description: String,
}

#[derive(Debug, Clone, PartialEq)]
pub enum Protocol {
    Tcp,
    Udp,
    Both,
}

impl From<&str> for Protocol {
    fn from(s: &str) -> Self {
        match s.to_lowercase().as_str() {
            "tcp" => Protocol::Tcp,
            "udp" => Protocol::Udp,
            _ => Protocol::Both,
        }
    }
}

impl fmt::Display for Protocol {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Protocol::Tcp => write!(f, "tcp"),
            Protocol::Udp => write!(f, "udp"),
            Protocol::Both => write!(f, "tcp/udp"),
        }
    }
}