|
|
@ -1,5 +1,5 @@ |
|
|
|
use std::{ |
|
|
|
use std::{ |
|
|
|
convert::{AsRef, From, Into}, |
|
|
|
convert::{AsRef, From, Into, TryFrom}, |
|
|
|
fmt, |
|
|
|
fmt, |
|
|
|
result::Result as StdResult, |
|
|
|
result::Result as StdResult, |
|
|
|
str, |
|
|
|
str, |
|
|
@ -270,32 +270,40 @@ impl Message { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl From<String> for Message { |
|
|
|
impl From<String> for Message { |
|
|
|
fn from(string: String) -> Message { |
|
|
|
fn from(string: String) -> Self { |
|
|
|
Message::text(string) |
|
|
|
Message::text(string) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl<'s> From<&'s str> for Message { |
|
|
|
impl<'s> From<&'s str> for Message { |
|
|
|
fn from(string: &'s str) -> Message { |
|
|
|
fn from(string: &'s str) -> Self { |
|
|
|
Message::text(string) |
|
|
|
Message::text(string) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl<'b> From<&'b [u8]> for Message { |
|
|
|
impl<'b> From<&'b [u8]> for Message { |
|
|
|
fn from(data: &'b [u8]) -> Message { |
|
|
|
fn from(data: &'b [u8]) -> Self { |
|
|
|
Message::binary(data) |
|
|
|
Message::binary(data) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl From<Vec<u8>> for Message { |
|
|
|
impl From<Vec<u8>> for Message { |
|
|
|
fn from(data: Vec<u8>) -> Message { |
|
|
|
fn from(data: Vec<u8>) -> Self { |
|
|
|
Message::binary(data) |
|
|
|
Message::binary(data) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl Into<Vec<u8>> for Message { |
|
|
|
impl From<Message> for Vec<u8> { |
|
|
|
fn into(self) -> Vec<u8> { |
|
|
|
fn from(message: Message) -> Self { |
|
|
|
self.into_data() |
|
|
|
message.into_data() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl TryFrom<Message> for String { |
|
|
|
|
|
|
|
type Error = Error; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn try_from(value: Message) -> StdResult<Self, Self::Error> { |
|
|
|
|
|
|
|
value.into_text() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|