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

@@ -27,13 +27,13 @@ parking_lot = { optional = true, version = "0.12" }
pin-project = "1" pin-project = "1"
rand = { optional = true, version = "0.8" } rand = { optional = true, version = "0.8" }
reqwest = { default-features = false, features = ["stream"], optional = true, version = "0.11" } 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" } rubato = { optional = true, version = "0.12" }
rusty_pool = { optional = true, version = "0.7" } rusty_pool = { optional = true, version = "0.7" }
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
serde-aux = { default-features = false, optional = true, version = "3"} serde-aux = { optional = true, version = "4"}
serde_json = "1" 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" } socket2 = { optional = true, version = "0.4" }
streamcatcher = { optional = true, version = "1" } streamcatcher = { optional = true, version = "1" }
tokio = { default-features = false, optional = true, version = "1.0" } tokio = { default-features = false, optional = true, version = "1.0" }
@@ -43,7 +43,7 @@ tracing = { version = "0.1", features = ["log"] }
tracing-futures = "0.2" tracing-futures = "0.2"
twilight-gateway = { default-features = false, optional = true, version = "0.14.0" } twilight-gateway = { default-features = false, optional = true, version = "0.14.0" }
twilight-model = { 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" } url = { optional = true, version = "2" }
uuid = { features = ["v4"], optional = true, version = "1" } uuid = { features = ["v4"], optional = true, version = "1" }
xsalsa20poly1305 = { features = ["std"], optional = true, version = "0.9" } xsalsa20poly1305 = { features = ["std"], optional = true, version = "0.9" }

View File

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

View File

@@ -89,10 +89,15 @@ impl From<TungsteniteError> for Error {
} }
#[inline] #[inline]
#[allow(unused_unsafe)]
pub(crate) fn convert_ws_message(message: Option<Message>) -> Result<Option<Event>> { pub(crate) fn convert_ws_message(message: Option<Message>) -> Result<Option<Event>> {
Ok(match message { 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)) => 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)) => { Some(Message::Binary(bytes)) => {
return Err(Error::UnexpectedBinaryMessage(bytes)); return Err(Error::UnexpectedBinaryMessage(bytes));
}, },