Skip to content

Commit

Permalink
Deps: Update Ringbuf, Serde-Aux, Simd-Json, Typemap
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixMcFelix committed Nov 20, 2023
1 parent 662debd commit 6a38fc8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ parking_lot = { optional = true, version = "0.12" }
pin-project = "1"
rand = { optional = true, version = "0.8" }
reqwest = { default-features = false, features = ["stream"], optional = true, version = "0.11" }
ringbuf = { optional = true, version = "0.2" }
ringbuf = { optional = true, version = "0.3" }
rubato = { optional = true, version = "0.12" }
rusty_pool = { optional = true, version = "0.7" }
serde = { version = "1", features = ["derive"] }
serde-aux = { default-features = false, optional = true, version = "3"}
serde-aux = { optional = true, version = "4"}
serde_json = "1"
simd-json = { features = ["serde_impl"], optional = true, version = "0.6.0" }
simd-json = { features = ["serde_impl"], optional = true, version = "0.7.0" }
socket2 = { optional = true, version = "0.4" }
streamcatcher = { optional = true, version = "1" }
tokio = { default-features = false, optional = true, version = "1.0" }
Expand All @@ -43,7 +43,7 @@ tracing = { version = "0.1", features = ["log"] }
tracing-futures = "0.2"
twilight-gateway = { default-features = false, optional = true, version = "0.14.0" }
twilight-model = { default-features = false, optional = true, version = "0.14.0" }
typemap_rev = { optional = true, version = "0.1" }
typemap_rev = { optional = true, version = "0.2" }
url = { optional = true, version = "2" }
uuid = { features = ["v4"], optional = true, version = "1" }
xsalsa20poly1305 = { features = ["std"], optional = true, version = "0.9" }
Expand Down
8 changes: 4 additions & 4 deletions src/input/adapters/async_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use tokio::{
};

struct AsyncAdapterSink {
bytes_in: Producer<u8>,
bytes_in: HeapProducer<u8>,
req_rx: Receiver<AdapterRequest>,
resp_tx: Sender<AdapterResponse>,
stream: Box<dyn AsyncMediaSource>,
Expand Down Expand Up @@ -135,7 +135,7 @@ impl AsyncAdapterSink {
/// pass along seek requests needed. This allows for passing bytes from exclusively `AsyncRead`
/// streams (e.g., hyper HTTP sessions) to Songbird.
pub struct AsyncAdapterStream {
bytes_out: Consumer<u8>,
bytes_out: HeapConsumer<u8>,
can_seek: bool,
// Note: this is Atomic just to work around the need for
// check_messages to take &self rather than &mut.
Expand All @@ -150,7 +150,7 @@ impl AsyncAdapterStream {
/// between the async and sync halves.
#[must_use]
pub fn new(stream: Box<dyn AsyncMediaSource>, buf_len: usize) -> AsyncAdapterStream {
let (bytes_in, bytes_out) = RingBuffer::new(buf_len).split();
let (bytes_in, bytes_out) = SharedRb::new(buf_len).split();
let (resp_tx, resp_rx) = flume::unbounded();
let (req_tx, req_rx) = flume::unbounded();
let can_seek = stream.is_seekable();
Expand Down Expand Up @@ -264,7 +264,7 @@ impl Seek for AsyncAdapterStream {
_ => unreachable!(),
}

self.bytes_out.discard(self.bytes_out.capacity());
self.bytes_out.skip(self.bytes_out.capacity());

let _ = self.req_tx.send(AdapterRequest::SeekCleared);

Expand Down
7 changes: 6 additions & 1 deletion src/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
},
Expand Down

0 comments on commit 6a38fc8

Please sign in to comment.