allow instantiating PortForwardProtocol from a string
This commit is contained in:
		| @@ -279,6 +279,7 @@ impl ConnectBox { | |||||||
| } | } | ||||||
|  |  | ||||||
| /// Specifies the action to perform with a given port forward. Used in conjunction with [`ConnectBox::edit_port_forwards`] | /// 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 { | pub enum PortForwardAction { | ||||||
|     /// Don't do anything with the port forward |     /// Don't do anything with the port forward | ||||||
|     Keep, |     Keep, | ||||||
|   | |||||||
| @@ -78,6 +78,16 @@ impl PortForwardProtocol { | |||||||
|             PortForwardProtocol::Both => "3", |             PortForwardProtocol::Both => "3", | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     #[must_use] | ||||||
|  |     pub fn new(s: &str) -> Option<Self> { | ||||||
|  |         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 { | impl<'de> Deserialize<'de> for PortForwardProtocol { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user