Gateway: Twilight v0.9 support (#110)
This handles twilight's migration to a unified `Id` type, which is the only design change needing any handling on our part. All our `From`/`Into`s are covered now, and deprecated type aliases are no longer used. This was tested using `cargo make ready` and by manually running "examples/twilight".
This commit is contained in:
23
src/id.rs
23
src/id.rs
@@ -11,9 +11,8 @@ use serenity::model::id::{
|
||||
use std::fmt::{Display, Formatter, Result as FmtResult};
|
||||
#[cfg(feature = "twilight")]
|
||||
use twilight_model::id::{
|
||||
ChannelId as TwilightChannel,
|
||||
GuildId as TwilightGuild,
|
||||
UserId as TwilightUser,
|
||||
marker::{ChannelMarker, GuildMarker, UserMarker},
|
||||
Id as TwilightId,
|
||||
};
|
||||
|
||||
/// ID of a Discord voice/text channel.
|
||||
@@ -48,9 +47,9 @@ impl From<SerenityChannel> for ChannelId {
|
||||
}
|
||||
|
||||
#[cfg(feature = "twilight")]
|
||||
impl From<TwilightChannel> for ChannelId {
|
||||
fn from(id: TwilightChannel) -> Self {
|
||||
Self(id.0.into())
|
||||
impl From<TwilightId<ChannelMarker>> for ChannelId {
|
||||
fn from(id: TwilightId<ChannelMarker>) -> Self {
|
||||
Self(id.get().into())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,9 +80,9 @@ impl From<GuildId> for DriverGuild {
|
||||
}
|
||||
|
||||
#[cfg(feature = "twilight")]
|
||||
impl From<TwilightGuild> for GuildId {
|
||||
fn from(id: TwilightGuild) -> Self {
|
||||
Self(id.0.into())
|
||||
impl From<TwilightId<GuildMarker>> for GuildId {
|
||||
fn from(id: TwilightId<GuildMarker>) -> Self {
|
||||
Self(id.get().into())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,8 +113,8 @@ impl From<UserId> for DriverUser {
|
||||
}
|
||||
|
||||
#[cfg(feature = "twilight")]
|
||||
impl From<TwilightUser> for UserId {
|
||||
fn from(id: TwilightUser) -> Self {
|
||||
Self(id.0.into())
|
||||
impl From<TwilightId<UserMarker>> for UserId {
|
||||
fn from(id: TwilightId<UserMarker>) -> Self {
|
||||
Self(id.get().into())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user