Add From<&T> for Box<T> implementations for ServerName, DeviceId
This commit is contained in:
parent
4cbdc079b0
commit
885aae39c5
@ -58,6 +58,12 @@ impl ToOwned for DeviceId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<&DeviceId> for Box<DeviceId> {
|
||||||
|
fn from(id: &DeviceId) -> Self {
|
||||||
|
id.to_owned()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl AsRef<str> for DeviceId {
|
impl AsRef<str> for DeviceId {
|
||||||
fn as_ref(&self) -> &str {
|
fn as_ref(&self) -> &str {
|
||||||
self.as_str()
|
self.as_str()
|
||||||
|
@ -48,6 +48,12 @@ impl ToOwned for ServerName {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<&ServerName> for Box<ServerName> {
|
||||||
|
fn from(s: &ServerName) -> Self {
|
||||||
|
s.to_owned()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn validate(server_name: &str) -> Result<(), Error> {
|
pub(crate) fn validate(server_name: &str) -> Result<(), Error> {
|
||||||
use std::net::Ipv6Addr;
|
use std::net::Ipv6Addr;
|
||||||
|
|
||||||
@ -114,8 +120,8 @@ impl AsRef<str> for Box<ServerName> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<Box<ServerName>> for String {
|
impl From<Box<ServerName>> for String {
|
||||||
fn from(id: Box<ServerName>) -> Self {
|
fn from(s: Box<ServerName>) -> Self {
|
||||||
id.into_owned().into()
|
s.into_owned().into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user