aboutsummaryrefslogtreecommitdiff
path: root/src/gateway
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-12-16 08:39:36 -0800
committerZeyla Hellyer <[email protected]>2017-12-16 08:45:26 -0800
commitbcd16dddb8cc3086a13524c79676f3a8bebbc524 (patch)
tree42d254fb4738df957c4b7d9e5766d1cb5bd47323 /src/gateway
parentFix guild deserialization tests (diff)
downloadserenity-bcd16dddb8cc3086a13524c79676f3a8bebbc524.tar.xz
serenity-bcd16dddb8cc3086a13524c79676f3a8bebbc524.zip
Break up the model module
The `model` module has historically been one giant module re-exporting all of the model types, which is somewhere around 100 types. This can be a lot to look at for a new user and somewhat overwhelming, especially with a large number of fine-grained imports from the module. The module is now neatly split up into submodules, mostly like it has been internally since the early versions of the library. The submodules are: - application - channel - error - event - gateway - guild - id - invite - misc - permissions - prelude - user - voice - webhook Each submodule contains types that are "owned" by the module. For example, the `guild` submodule contains, but not limited to, Emoji, AuditLogsEntry, Role, and Member. `channel` contains, but not limited to, Attachment, Embed, Message, and Reaction. Upgrade path: Instead of glob importing the models via `use serenity::model::*;`, instead glob import via the prelude: ```rust use serenity::model::prelude::*; ``` Instead of importing from the root model module: ```rust use serenity::model::{Guild, Message, OnlineStatus, Role, User}; ``` instead import from the submodules like so: ```rust use serenity::model::channel::Message; use serenity::model::guild::{Guild, Role}; use serenity::model::user::{OnlineStatus, User}; ```
Diffstat (limited to 'src/gateway')
-rw-r--r--src/gateway/mod.rs3
-rw-r--r--src/gateway/shard.rs10
-rw-r--r--src/gateway/ws_client_ext.rs2
3 files changed, 9 insertions, 6 deletions
diff --git a/src/gateway/mod.rs b/src/gateway/mod.rs
index c2acaac..7e4e2b0 100644
--- a/src/gateway/mod.rs
+++ b/src/gateway/mod.rs
@@ -57,7 +57,8 @@ pub use self::error::Error as GatewayError;
pub use self::shard::Shard;
pub use self::ws_client_ext::WebSocketGatewayClientExt;
-use model::{Game, OnlineStatus};
+use model::gateway::Game;
+use model::user::OnlineStatus;
use websocket::sync::client::Client;
use websocket::sync::stream::{TcpStream, TlsStream};
diff --git a/src/gateway/shard.rs b/src/gateway/shard.rs
index 333d693..c00affc 100644
--- a/src/gateway/shard.rs
+++ b/src/gateway/shard.rs
@@ -1,7 +1,9 @@
use constants::{self, close_codes};
use internal::prelude::*;
use model::event::{Event, GatewayEvent};
-use model::{Game, GuildId, OnlineStatus};
+use model::gateway::Game;
+use model::id::GuildId;
+use model::user::OnlineStatus;
use parking_lot::Mutex;
use std::sync::Arc;
use std::time::{Duration as StdDuration, Instant};
@@ -297,7 +299,7 @@ impl Shard {
/// #
/// # let mut shard = Shard::new(mutex.clone(), mutex, [0, 1]).unwrap();
/// #
- /// use serenity::model::Game;
+ /// use serenity::model::gateway::Game;
///
/// shard.set_game(Some(Game::playing("Heroes of the Storm")));
/// # }
@@ -755,7 +757,7 @@ impl Shard {
/// #
/// # let mut shard = Shard::new(mutex.clone(), mutex, [0, 1])?;
/// #
- /// use serenity::model::GuildId;
+ /// use serenity::model::id::GuildId;
///
/// let guild_ids = vec![GuildId(81384788765712384)];
///
@@ -785,7 +787,7 @@ impl Shard {
/// #
/// # let mut shard = Shard::new(mutex.clone(), mutex, [0, 1])?;
/// #
- /// use serenity::model::GuildId;
+ /// use serenity::model::id::GuildId;
///
/// let guild_ids = vec![GuildId(81384788765712384)];
///
diff --git a/src/gateway/ws_client_ext.rs b/src/gateway/ws_client_ext.rs
index 873d114..934383c 100644
--- a/src/gateway/ws_client_ext.rs
+++ b/src/gateway/ws_client_ext.rs
@@ -3,7 +3,7 @@ use constants::{self, OpCode};
use gateway::{CurrentPresence, WsClient};
use internal::prelude::*;
use internal::ws_impl::SenderExt;
-use model::GuildId;
+use model::id::GuildId;
use std::env::consts;
pub trait WebSocketGatewayClientExt {