Driver, Gateway: Remove tokio 0.2 support (#118)
* Remove tokio 0.2 compat * Remove tokio 0.2 test * Remove tokio 0.2 CI
This commit is contained in:
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@@ -56,9 +56,6 @@ jobs:
|
|||||||
- name: gateway only
|
- name: gateway only
|
||||||
features: serenity-rustls
|
features: serenity-rustls
|
||||||
dont-test: true
|
dont-test: true
|
||||||
- name: legacy tokio
|
|
||||||
features: serenity-rustls-tokio-02 driver-tokio-02
|
|
||||||
dont-test: true
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
|
|||||||
39
Cargo.toml
39
Cargo.toml
@@ -30,13 +30,6 @@ features = ["tokio-runtime"]
|
|||||||
optional = true
|
optional = true
|
||||||
version = "0.14"
|
version = "0.14"
|
||||||
|
|
||||||
[dependencies.async-tungstenite-compat]
|
|
||||||
package = "async-tungstenite"
|
|
||||||
default-features = false
|
|
||||||
features = ["tokio-runtime"]
|
|
||||||
optional = true
|
|
||||||
version = "0.9"
|
|
||||||
|
|
||||||
[dependencies.audiopus]
|
[dependencies.audiopus]
|
||||||
optional = true
|
optional = true
|
||||||
version = "0.2"
|
version = "0.2"
|
||||||
@@ -97,12 +90,6 @@ optional = true
|
|||||||
version = "1.0"
|
version = "1.0"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[dependencies.tokio-compat]
|
|
||||||
optional = true
|
|
||||||
package = "tokio"
|
|
||||||
version = "0.2"
|
|
||||||
default-features = false
|
|
||||||
|
|
||||||
[dependencies.twilight-gateway]
|
[dependencies.twilight-gateway]
|
||||||
optional = true
|
optional = true
|
||||||
version = ">=0.9.0, <0.11.0"
|
version = ">=0.9.0, <0.11.0"
|
||||||
@@ -195,32 +182,6 @@ serenity-deps = ["async-trait"]
|
|||||||
rustls-marker = []
|
rustls-marker = []
|
||||||
native-marker = []
|
native-marker = []
|
||||||
|
|
||||||
# Tokio 0.2 Compatibility features
|
|
||||||
# These should probably be dropped around the same time as serenity drop them.
|
|
||||||
rustls-tokio-02 = ["async-tungstenite-compat/tokio-rustls", "rustls-marker", "tokio-02-marker"]
|
|
||||||
native-tokio-02 = ["async-tungstenite-compat/tokio-native-tls", "native-marker", "tokio-02-marker"]
|
|
||||||
serenity-rustls-tokio-02 = ["serenity/rustls_tokio_0_2_backend", "rustls-tokio-02", "gateway-tokio-02", "serenity-deps"]
|
|
||||||
serenity-native-tokio-02 = ["serenity/native_tls_tokio_0_2_backend", "native-tokio-02", "gateway-tokio-02", "serenity-deps"]
|
|
||||||
gateway-tokio-02 = [
|
|
||||||
"gateway-core",
|
|
||||||
"tokio-02-marker",
|
|
||||||
"tokio-compat/sync",
|
|
||||||
]
|
|
||||||
driver-tokio-02 = [
|
|
||||||
"async-tungstenite-compat",
|
|
||||||
"driver-core",
|
|
||||||
"tokio-02-marker",
|
|
||||||
"tokio-compat/fs",
|
|
||||||
"tokio-compat/io-util",
|
|
||||||
"tokio-compat/macros",
|
|
||||||
"tokio-compat/net",
|
|
||||||
"tokio-compat/process",
|
|
||||||
"tokio-compat/rt-core",
|
|
||||||
"tokio-compat/sync",
|
|
||||||
"tokio-compat/time",
|
|
||||||
]
|
|
||||||
tokio-02-marker = []
|
|
||||||
|
|
||||||
# Behaviour altering features.
|
# Behaviour altering features.
|
||||||
youtube-dlc = []
|
youtube-dlc = []
|
||||||
yt-dlp = []
|
yt-dlp = []
|
||||||
|
|||||||
@@ -23,13 +23,8 @@ args = ["build", "--no-default-features", "--features", "driver,rustls"]
|
|||||||
command = "cargo"
|
command = "cargo"
|
||||||
dependencies = ["format"]
|
dependencies = ["format"]
|
||||||
|
|
||||||
[tasks.build-old-tokio]
|
|
||||||
command = "cargo"
|
|
||||||
args = ["build", "--no-default-features", "--features", "serenity-rustls-tokio-02,driver-tokio-02"]
|
|
||||||
dependencies = ["format"]
|
|
||||||
|
|
||||||
[tasks.build-variants]
|
[tasks.build-variants]
|
||||||
dependencies = ["build", "build-gateway", "build-driver", "build-old-tokio"]
|
dependencies = ["build", "build-gateway", "build-driver"]
|
||||||
|
|
||||||
[tasks.clippy]
|
[tasks.clippy]
|
||||||
args = ["clippy", "--features", "full-doc", "--", "-D", "warnings"]
|
args = ["clippy", "--features", "full-doc", "--", "-D", "warnings"]
|
||||||
|
|||||||
@@ -7,10 +7,7 @@ use crate::{
|
|||||||
use flume::SendError;
|
use flume::SendError;
|
||||||
use serde_json::Error as JsonError;
|
use serde_json::Error as JsonError;
|
||||||
use std::{error::Error as StdError, fmt, io::Error as IoError};
|
use std::{error::Error as StdError, fmt, io::Error as IoError};
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use tokio::time::error::Elapsed;
|
use tokio::time::error::Elapsed;
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use tokio_compat::time::Elapsed;
|
|
||||||
use xsalsa20poly1305::aead::Error as CryptoError;
|
use xsalsa20poly1305::aead::Error as CryptoError;
|
||||||
|
|
||||||
/// Errors encountered while connecting to a Discord voice server over the driver.
|
/// Errors encountered while connecting to a Discord voice server over the driver.
|
||||||
|
|||||||
@@ -19,10 +19,7 @@ use discortp::discord::{IpDiscoveryPacket, IpDiscoveryType, MutableIpDiscoveryPa
|
|||||||
use error::{Error, Result};
|
use error::{Error, Result};
|
||||||
use flume::Sender;
|
use flume::Sender;
|
||||||
use std::{net::IpAddr, str::FromStr, sync::Arc};
|
use std::{net::IpAddr, str::FromStr, sync::Arc};
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use tokio::{net::UdpSocket, spawn, time::timeout};
|
use tokio::{net::UdpSocket, spawn, time::timeout};
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use tokio_compat::{net::UdpSocket, spawn, time::timeout};
|
|
||||||
use tracing::{debug, info, instrument};
|
use tracing::{debug, info, instrument};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use xsalsa20poly1305::{aead::NewAead, XSalsa20Poly1305 as Cipher};
|
use xsalsa20poly1305::{aead::NewAead, XSalsa20Poly1305 as Cipher};
|
||||||
@@ -115,11 +112,7 @@ impl Connection {
|
|||||||
return Err(Error::CryptoModeUnavailable);
|
return Err(Error::CryptoModeUnavailable);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
let udp = UdpSocket::bind("0.0.0.0:0").await?;
|
let udp = UdpSocket::bind("0.0.0.0:0").await?;
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
let mut udp = UdpSocket::bind("0.0.0.0:0").await?;
|
|
||||||
|
|
||||||
udp.connect((ready.ip, ready.port)).await?;
|
udp.connect((ready.ip, ready.port)).await?;
|
||||||
|
|
||||||
// Follow Discord's IP Discovery procedures, in case NAT tunnelling is needed.
|
// Follow Discord's IP Discovery procedures, in case NAT tunnelling is needed.
|
||||||
@@ -184,14 +177,11 @@ impl Connection {
|
|||||||
let (udp_sender_msg_tx, udp_sender_msg_rx) = flume::unbounded();
|
let (udp_sender_msg_tx, udp_sender_msg_rx) = flume::unbounded();
|
||||||
let (udp_receiver_msg_tx, udp_receiver_msg_rx) = flume::unbounded();
|
let (udp_receiver_msg_tx, udp_receiver_msg_rx) = flume::unbounded();
|
||||||
|
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
let (udp_rx, udp_tx) = {
|
let (udp_rx, udp_tx) = {
|
||||||
let udp_rx = Arc::new(udp);
|
let udp_rx = Arc::new(udp);
|
||||||
let udp_tx = Arc::clone(&udp_rx);
|
let udp_tx = Arc::clone(&udp_rx);
|
||||||
(udp_rx, udp_tx)
|
(udp_rx, udp_tx)
|
||||||
};
|
};
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
let (udp_rx, udp_tx) = udp.split();
|
|
||||||
|
|
||||||
let ssrc = ready.ssrc;
|
let ssrc = ready.ssrc;
|
||||||
|
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ mod ws;
|
|||||||
pub use self::{core::*, disposal::*, events::*, mixer::*, udp_rx::*, udp_tx::*, ws::*};
|
pub use self::{core::*, disposal::*, events::*, mixer::*, udp_rx::*, udp_tx::*, ws::*};
|
||||||
|
|
||||||
use flume::Sender;
|
use flume::Sender;
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use tokio::spawn;
|
use tokio::spawn;
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use tokio_compat::spawn;
|
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|||||||
@@ -19,10 +19,7 @@ use flume::{Receiver, Sender, TryRecvError};
|
|||||||
use rand::random;
|
use rand::random;
|
||||||
use spin_sleep::SpinSleeper;
|
use spin_sleep::SpinSleeper;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use tokio::runtime::Handle;
|
use tokio::runtime::Handle;
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use tokio_compat::runtime::Handle;
|
|
||||||
use tracing::{debug, error, instrument};
|
use tracing::{debug, error, instrument};
|
||||||
use xsalsa20poly1305::TAG_SIZE;
|
use xsalsa20poly1305::TAG_SIZE;
|
||||||
|
|
||||||
|
|||||||
@@ -23,10 +23,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use flume::{Receiver, RecvError, Sender};
|
use flume::{Receiver, RecvError, Sender};
|
||||||
use message::*;
|
use message::*;
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use tokio::{runtime::Handle, spawn, time::sleep as tsleep};
|
use tokio::{runtime::Handle, spawn, time::sleep as tsleep};
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use tokio_compat::{runtime::Handle, spawn, time::delay_for as tsleep};
|
|
||||||
use tracing::{debug, instrument, trace};
|
use tracing::{debug, instrument, trace};
|
||||||
|
|
||||||
pub(crate) fn start(config: Config, rx: Receiver<CoreMessage>, tx: Sender<CoreMessage>) {
|
pub(crate) fn start(config: Config, rx: Receiver<CoreMessage>, tx: Sender<CoreMessage>) {
|
||||||
|
|||||||
@@ -22,10 +22,7 @@ use discortp::{
|
|||||||
};
|
};
|
||||||
use flume::Receiver;
|
use flume::Receiver;
|
||||||
use std::{collections::HashMap, sync::Arc};
|
use std::{collections::HashMap, sync::Arc};
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use tokio::{net::UdpSocket, select};
|
use tokio::{net::UdpSocket, select};
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use tokio_compat::{net::udp::RecvHalf, select};
|
|
||||||
use tracing::{error, instrument, trace, warn};
|
use tracing::{error, instrument, trace, warn};
|
||||||
use xsalsa20poly1305::XSalsa20Poly1305 as Cipher;
|
use xsalsa20poly1305::XSalsa20Poly1305 as Cipher;
|
||||||
|
|
||||||
@@ -241,10 +238,7 @@ struct UdpRx {
|
|||||||
packet_buffer: [u8; VOICE_PACKET_MAX],
|
packet_buffer: [u8; VOICE_PACKET_MAX],
|
||||||
rx: Receiver<UdpRxMessage>,
|
rx: Receiver<UdpRxMessage>,
|
||||||
|
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
udp_socket: Arc<UdpSocket>,
|
udp_socket: Arc<UdpSocket>,
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
udp_socket: RecvHalf,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UdpRx {
|
impl UdpRx {
|
||||||
@@ -396,7 +390,6 @@ impl UdpRx {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
#[instrument(skip(interconnect, rx, cipher))]
|
#[instrument(skip(interconnect, rx, cipher))]
|
||||||
pub(crate) async fn runner(
|
pub(crate) async fn runner(
|
||||||
mut interconnect: Interconnect,
|
mut interconnect: Interconnect,
|
||||||
@@ -421,31 +414,6 @@ pub(crate) async fn runner(
|
|||||||
trace!("UDP receive handle stopped.");
|
trace!("UDP receive handle stopped.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
#[instrument(skip(interconnect, rx, cipher))]
|
|
||||||
pub(crate) async fn runner(
|
|
||||||
mut interconnect: Interconnect,
|
|
||||||
rx: Receiver<UdpRxMessage>,
|
|
||||||
cipher: Cipher,
|
|
||||||
config: Config,
|
|
||||||
udp_socket: RecvHalf,
|
|
||||||
) {
|
|
||||||
trace!("UDP receive handle started.");
|
|
||||||
|
|
||||||
let mut state = UdpRx {
|
|
||||||
cipher,
|
|
||||||
decoder_map: Default::default(),
|
|
||||||
config,
|
|
||||||
packet_buffer: [0u8; VOICE_PACKET_MAX],
|
|
||||||
rx,
|
|
||||||
udp_socket,
|
|
||||||
};
|
|
||||||
|
|
||||||
state.run(&mut interconnect).await;
|
|
||||||
|
|
||||||
trace!("UDP receive handle stopped.");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn rtp_valid(packet: RtpPacket<'_>) -> bool {
|
fn rtp_valid(packet: RtpPacket<'_>) -> bool {
|
||||||
packet.get_version() == RTP_VERSION && packet.get_payload_type() == RTP_PROFILE_TYPE
|
packet.get_version() == RTP_VERSION && packet.get_payload_type() == RTP_PROFILE_TYPE
|
||||||
|
|||||||
@@ -3,26 +3,17 @@ use crate::constants::*;
|
|||||||
use discortp::discord::MutableKeepalivePacket;
|
use discortp::discord::MutableKeepalivePacket;
|
||||||
use flume::Receiver;
|
use flume::Receiver;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use tokio::{
|
use tokio::{
|
||||||
net::UdpSocket,
|
net::UdpSocket,
|
||||||
time::{timeout_at, Instant},
|
time::{timeout_at, Instant},
|
||||||
};
|
};
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use tokio_compat::{
|
|
||||||
net::udp::SendHalf,
|
|
||||||
time::{timeout_at, Instant},
|
|
||||||
};
|
|
||||||
use tracing::{error, instrument, trace};
|
use tracing::{error, instrument, trace};
|
||||||
|
|
||||||
struct UdpTx {
|
struct UdpTx {
|
||||||
ssrc: u32,
|
ssrc: u32,
|
||||||
rx: Receiver<UdpTxMessage>,
|
rx: Receiver<UdpTxMessage>,
|
||||||
|
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
udp_tx: Arc<UdpSocket>,
|
udp_tx: Arc<UdpSocket>,
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
udp_tx: SendHalf,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UdpTx {
|
impl UdpTx {
|
||||||
@@ -62,7 +53,6 @@ impl UdpTx {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
#[instrument(skip(udp_msg_rx))]
|
#[instrument(skip(udp_msg_rx))]
|
||||||
pub(crate) async fn runner(udp_msg_rx: Receiver<UdpTxMessage>, ssrc: u32, udp_tx: Arc<UdpSocket>) {
|
pub(crate) async fn runner(udp_msg_rx: Receiver<UdpTxMessage>, ssrc: u32, udp_tx: Arc<UdpSocket>) {
|
||||||
trace!("UDP transmit handle started.");
|
trace!("UDP transmit handle started.");
|
||||||
@@ -77,19 +67,3 @@ pub(crate) async fn runner(udp_msg_rx: Receiver<UdpTxMessage>, ssrc: u32, udp_tx
|
|||||||
|
|
||||||
trace!("UDP transmit handle stopped.");
|
trace!("UDP transmit handle stopped.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
#[instrument(skip(udp_msg_rx))]
|
|
||||||
pub(crate) async fn runner(udp_msg_rx: Receiver<UdpTxMessage>, ssrc: u32, udp_tx: SendHalf) {
|
|
||||||
trace!("UDP transmit handle started.");
|
|
||||||
|
|
||||||
let mut txer = UdpTx {
|
|
||||||
ssrc,
|
|
||||||
rx: udp_msg_rx,
|
|
||||||
udp_tx,
|
|
||||||
};
|
|
||||||
|
|
||||||
txer.run().await;
|
|
||||||
|
|
||||||
trace!("UDP transmit handle stopped.");
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -11,23 +11,14 @@ use crate::{
|
|||||||
ws::{Error as WsError, ReceiverExt, SenderExt, WsStream},
|
ws::{Error as WsError, ReceiverExt, SenderExt, WsStream},
|
||||||
ConnectionInfo,
|
ConnectionInfo,
|
||||||
};
|
};
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use async_tungstenite::tungstenite::protocol::frame::coding::CloseCode;
|
use async_tungstenite::tungstenite::protocol::frame::coding::CloseCode;
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use async_tungstenite_compat::tungstenite::protocol::frame::coding::CloseCode;
|
|
||||||
use flume::Receiver;
|
use flume::Receiver;
|
||||||
use rand::random;
|
use rand::random;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use tokio::{
|
use tokio::{
|
||||||
select,
|
select,
|
||||||
time::{sleep_until, Instant},
|
time::{sleep_until, Instant},
|
||||||
};
|
};
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use tokio_compat::{
|
|
||||||
select,
|
|
||||||
time::{delay_until as sleep_until, Instant},
|
|
||||||
};
|
|
||||||
use tracing::{debug, info, instrument, trace, warn};
|
use tracing::{debug, info, instrument, trace, warn};
|
||||||
|
|
||||||
struct AuxNetwork {
|
struct AuxNetwork {
|
||||||
|
|||||||
@@ -4,10 +4,7 @@ use crate::{
|
|||||||
model::{CloseCode as VoiceCloseCode, FromPrimitive},
|
model::{CloseCode as VoiceCloseCode, FromPrimitive},
|
||||||
ws::Error as WsError,
|
ws::Error as WsError,
|
||||||
};
|
};
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use async_tungstenite::tungstenite::protocol::frame::coding::CloseCode;
|
use async_tungstenite::tungstenite::protocol::frame::coding::CloseCode;
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use async_tungstenite_compat::tungstenite::protocol::frame::coding::CloseCode;
|
|
||||||
|
|
||||||
/// Voice connection details gathered at termination or failure.
|
/// Voice connection details gathered at termination or failure.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -4,10 +4,7 @@ use std::{
|
|||||||
mem,
|
mem,
|
||||||
process::Child,
|
process::Child,
|
||||||
};
|
};
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use tokio::runtime::Handle;
|
use tokio::runtime::Handle;
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use tokio_compat::runtime::Handle;
|
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
/// Handle for a child process which ensures that any subprocesses are properly closed
|
/// Handle for a child process which ensures that any subprocesses are properly closed
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
use super::{codec::OpusDecoderState, error::DcaError, Codec, Container, Input, Metadata, Reader};
|
use super::{codec::OpusDecoderState, error::DcaError, Codec, Container, Input, Metadata, Reader};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::{ffi::OsStr, mem};
|
use std::{ffi::OsStr, mem};
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use tokio::{fs::File as TokioFile, io::AsyncReadExt};
|
use tokio::{fs::File as TokioFile, io::AsyncReadExt};
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use tokio_compat::{fs::File as TokioFile, io::AsyncReadExt};
|
|
||||||
|
|
||||||
/// Creates a streamed audio source from a DCA file.
|
/// Creates a streamed audio source from a DCA file.
|
||||||
/// Currently only accepts the [DCA1 format](https://github.com/bwmarrin/dca).
|
/// Currently only accepts the [DCA1 format](https://github.com/bwmarrin/dca).
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ use std::{
|
|||||||
ffi::OsStr,
|
ffi::OsStr,
|
||||||
process::{Command, Stdio},
|
process::{Command, Stdio},
|
||||||
};
|
};
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use tokio::process::Command as TokioCommand;
|
use tokio::process::Command as TokioCommand;
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use tokio_compat::process::Command as TokioCommand;
|
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
/// Opens an audio file through `ffmpeg` and creates an audio source.
|
/// Opens an audio file through `ffmpeg` and creates an audio source.
|
||||||
|
|||||||
@@ -58,10 +58,7 @@ use audiopus::coder::GenericCtl;
|
|||||||
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
||||||
use cached::OpusCompressor;
|
use cached::OpusCompressor;
|
||||||
use error::{Error, Result};
|
use error::{Error, Result};
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use tokio::runtime::Handle;
|
use tokio::runtime::Handle;
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use tokio_compat::runtime::Handle;
|
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
convert::TryFrom,
|
convert::TryFrom,
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ use std::{
|
|||||||
io::{BufRead, BufReader, Read},
|
io::{BufRead, BufReader, Read},
|
||||||
process::{Command, Stdio},
|
process::{Command, Stdio},
|
||||||
};
|
};
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use tokio::{process::Command as TokioCommand, task};
|
use tokio::{process::Command as TokioCommand, task};
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use tokio_compat::{process::Command as TokioCommand, task};
|
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
|
|
||||||
const YOUTUBE_DL_COMMAND: &str = if cfg!(feature = "youtube-dlc") {
|
const YOUTUBE_DL_COMMAND: &str = if cfg!(feature = "youtube-dlc") {
|
||||||
|
|||||||
@@ -16,10 +16,7 @@ use core::{
|
|||||||
};
|
};
|
||||||
use flume::r#async::RecvFut;
|
use flume::r#async::RecvFut;
|
||||||
use pin_project::pin_project;
|
use pin_project::pin_project;
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use tokio::time::{self, Timeout};
|
use tokio::time::{self, Timeout};
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use tokio_compat::time::{self, Timeout};
|
|
||||||
|
|
||||||
#[cfg(feature = "driver-core")]
|
#[cfg(feature = "driver-core")]
|
||||||
/// Future for a call to [`Call::join`].
|
/// Future for a call to [`Call::join`].
|
||||||
|
|||||||
@@ -22,10 +22,7 @@ use serenity::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use tokio_compat::sync::Mutex;
|
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
#[cfg(feature = "twilight")]
|
#[cfg(feature = "twilight")]
|
||||||
use twilight_gateway::Cluster;
|
use twilight_gateway::Cluster;
|
||||||
|
|||||||
@@ -5,10 +5,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use flume::Sender;
|
use flume::Sender;
|
||||||
use std::{fmt, sync::Arc, time::Duration};
|
use std::{fmt, sync::Arc, time::Duration};
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use tokio_compat::sync::RwLock;
|
|
||||||
use typemap_rev::TypeMap;
|
use typemap_rev::TypeMap;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
|||||||
11
src/ws.rs
11
src/ws.rs
@@ -1,26 +1,15 @@
|
|||||||
use crate::model::Event;
|
use crate::model::Event;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use async_tungstenite::{
|
use async_tungstenite::{
|
||||||
self as tungstenite,
|
self as tungstenite,
|
||||||
tokio::ConnectStream,
|
tokio::ConnectStream,
|
||||||
tungstenite::{error::Error as TungsteniteError, protocol::CloseFrame, Message},
|
tungstenite::{error::Error as TungsteniteError, protocol::CloseFrame, Message},
|
||||||
WebSocketStream,
|
WebSocketStream,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use async_tungstenite_compat::{
|
|
||||||
self as tungstenite,
|
|
||||||
tokio::ConnectStream,
|
|
||||||
tungstenite::{error::Error as TungsteniteError, protocol::CloseFrame, Message},
|
|
||||||
WebSocketStream,
|
|
||||||
};
|
|
||||||
use futures::{SinkExt, StreamExt, TryStreamExt};
|
use futures::{SinkExt, StreamExt, TryStreamExt};
|
||||||
use serde_json::Error as JsonError;
|
use serde_json::Error as JsonError;
|
||||||
#[cfg(not(feature = "tokio-02-marker"))]
|
|
||||||
use tokio::time::{timeout, Duration};
|
use tokio::time::{timeout, Duration};
|
||||||
#[cfg(feature = "tokio-02-marker")]
|
|
||||||
use tokio_compat::time::{timeout, Duration};
|
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
pub type WsStream = WebSocketStream<ConnectStream>;
|
pub type WsStream = WebSocketStream<ConnectStream>;
|
||||||
|
|||||||
Reference in New Issue
Block a user