mirror of
https://github.com/tokio-rs/axum.git
synced 2025-01-01 00:50:32 +01:00
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:
parent
5a11ae8960
commit
fef95bf37a
2 changed files with 27 additions and 0 deletions
|
@ -40,6 +40,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
you likely need to re-enable the `tokio` feature ([#1382])
|
||||
- **breaking:** `handler::{WithState, IntoService}` are merged into one type,
|
||||
named `HandlerService` ([#1418])
|
||||
- **added:** String and binary `From` impls have been added to `extract::ws::Message`
|
||||
to be more inline with `tungstenite` ([#1421])
|
||||
|
||||
[#1368]: https://github.com/tokio-rs/axum/pull/1368
|
||||
[#1371]: https://github.com/tokio-rs/axum/pull/1371
|
||||
|
@ -52,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
[#1408]: https://github.com/tokio-rs/axum/pull/1408
|
||||
[#1414]: https://github.com/tokio-rs/axum/pull/1414
|
||||
[#1418]: https://github.com/tokio-rs/axum/pull/1418
|
||||
[#1421]: https://github.com/tokio-rs/axum/pull/1421
|
||||
|
||||
# 0.6.0-rc.2 (10. September, 2022)
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue