Update async-tungstenite version

This commit is contained in:
Joakim Frostegård 2025-01-12 22:35:07 +01:00
parent edc85a0f66
commit 34902048d9
6 changed files with 25 additions and 386 deletions

View file

@ -29,8 +29,8 @@ anyhow = "1"
hashbrown = { version = "0.15", features = ["serde"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
simd-json = "0.13"
tungstenite = { version = "0.21", optional = true }
simd-json = "0.14"
tungstenite = { version = "0.24", optional = true }
[dev-dependencies]
criterion = "0.5"

View file

@ -28,11 +28,13 @@ impl InMessage {
match ws_message {
Message::Text(text) => {
let mut text: Vec<u8> = text.into();
let mut text: Vec<u8> = text.as_bytes().to_owned();
::simd_json::serde::from_slice(&mut text).context("deserialize with serde")
}
Message::Binary(mut bytes) => {
Message::Binary(bytes) => {
let mut bytes = bytes.to_vec();
::simd_json::serde::from_slice(&mut bytes[..]).context("deserialize with serde")
}
_ => Err(anyhow::anyhow!("Message is neither text nor binary")),

View file

@ -35,8 +35,8 @@ impl OutMessage {
use tungstenite::Message::{Binary, Text};
let mut text: Vec<u8> = match message {
Text(text) => text.into(),
Binary(bytes) => String::from_utf8(bytes)?.into(),
Text(text) => text.as_bytes().to_owned(),
Binary(bytes) => String::from_utf8(bytes.to_vec())?.into(),
_ => return Err(anyhow::anyhow!("Message is neither text nor bytes")),
};