Made conversion into 'SocketType' enum more generic
Now it works for anything that can be converted into String
This commit is contained in:
@@ -39,15 +39,9 @@ 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();
|
||||
impl SocketType {
|
||||
pub fn from_string<S: Into<String>>(val: S) -> Self {
|
||||
let mut upper = val.into();
|
||||
upper.make_ascii_uppercase();
|
||||
match upper.as_ref() {
|
||||
"TCP" => SocketType::TCP,
|
||||
|
||||
Reference in New Issue
Block a user