Implement From<Bytes> for Message (#3273)

This commit is contained in:
Andrei Nesterov
2025-03-17 14:15:15 +00:00
committed by GitHub
parent f479e0d617
commit c997137383
2 changed files with 12 additions and 0 deletions
+6
View File
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
# Unreleased
- **added:** Implement `From<Bytes>` for `Message` ([#3273])
[#3273]: https://github.com/tokio-rs/axum/pull/3273
# 0.8.2
- **added:** Implement `OptionalFromRequest` for `Json` ([#3142])
+6
View File
@@ -858,6 +858,12 @@ impl<'b> From<&'b [u8]> for Message {
}
}
impl From<Bytes> for Message {
fn from(data: Bytes) -> Self {
Message::Binary(data)
}
}
impl From<Vec<u8>> for Message {
fn from(data: Vec<u8>) -> Self {
Message::Binary(data.into())