Add From impls for extract::ws::Message (#1421)

* Add From impls for extract::ws::Message

These come from tungstenite but were not exposed by axum

* Add changelog entry
This commit is contained in:
Danny
2022-09-26 19:07:12 +00:00
committed by GitHub
parent 5a11ae8960
commit fef95bf37a
2 changed files with 27 additions and 0 deletions
+24
View File
@@ -545,6 +545,30 @@ impl Message {
}
}
impl From<String> for Message {
fn from(string: String) -> Self {
Message::Text(string)
}
}
impl<'s> From<&'s str> for Message {
fn from(string: &'s str) -> Self {
Message::Text(string.into())
}
}
impl<'b> From<&'b [u8]> for Message {
fn from(data: &'b [u8]) -> Self {
Message::Binary(data.into())
}
}
impl From<Vec<u8>> for Message {
fn from(data: Vec<u8>) -> Self {
Message::Binary(data)
}
}
impl From<Message> for Vec<u8> {
fn from(msg: Message) -> Self {
msg.into_data()