diff --git a/connectbox/src/lib.rs b/connectbox/src/lib.rs index 99eb6b1..15c482a 100644 --- a/connectbox/src/lib.rs +++ b/connectbox/src/lib.rs @@ -279,6 +279,7 @@ impl ConnectBox { } /// Specifies the action to perform with a given port forward. Used in conjunction with [`ConnectBox::edit_port_forwards`] +#[derive(Debug, Clone, Copy)] pub enum PortForwardAction { /// Don't do anything with the port forward Keep, diff --git a/connectbox/src/models.rs b/connectbox/src/models.rs index a64d8a7..29a4a9b 100644 --- a/connectbox/src/models.rs +++ b/connectbox/src/models.rs @@ -78,6 +78,16 @@ impl PortForwardProtocol { PortForwardProtocol::Both => "3", } } + + #[must_use] + pub fn new(s: &str) -> Option { + match s.to_lowercase().as_str() { + "tcp" => Some(Self::Tcp), + "udp" => Some(Self::Udp), + "both" => Some(Self::Both), + _ => None, + } + } } impl<'de> Deserialize<'de> for PortForwardProtocol {