Ability to convert SocketType from &str or String

This commit is contained in:
Jedrzej Stuczynski
2020-01-30 17:06:45 +00:00
parent b27b619412
commit af5c389eea
+18
View File
@@ -39,6 +39,24 @@ pub enum SocketType {
None,
}
impl From<String> for SocketType {
fn from(v: String) -> Self {
Self::from(v.as_ref())
}
}
impl From<&str> for SocketType {
fn from(v: &str) -> Self {
let mut upper = v.to_string();
upper.make_ascii_uppercase();
match upper.as_ref() {
"TCP" => SocketType::TCP,
"WEBSOCKET" => SocketType::WebSocket,
_ => SocketType::None,
}
}
}
pub struct NymClient {
keypair: MixIdentityKeyPair,