Deps: Update Ringbuf, Serde-Aux, Simd-Json, Typemap

This commit is contained in:
Kyle Simpson
2022-11-20 18:35:08 +00:00
parent 662debd414
commit 6a38fc82f4
3 changed files with 14 additions and 9 deletions

View File

@@ -89,10 +89,15 @@ impl From<TungsteniteError> for Error {
}
#[inline]
#[allow(unused_unsafe)]
pub(crate) fn convert_ws_message(message: Option<Message>) -> Result<Option<Event>> {
Ok(match message {
// SAFETY:
// simd-json::serde::from_str may leave an &mut str in a non-UTF state on failure.
// The below is safe as we have taken ownership of the inner `String`, and don't
// access it as a `str`/`String` or return it if failure occurs.
Some(Message::Text(mut payload)) =>
crate::json::from_str(payload.as_mut_str()).map(Some)?,
unsafe { crate::json::from_str(payload.as_mut_str()) }.map(Some)?,
Some(Message::Binary(bytes)) => {
return Err(Error::UnexpectedBinaryMessage(bytes));
},