From bcd16dddb8cc3086a13524c79676f3a8bebbc524 Mon Sep 17 00:00:00 2001 From: Zeyla Hellyer Date: Sat, 16 Dec 2017 08:39:36 -0800 Subject: 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}; ``` --- src/builder/edit_guild.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/builder/edit_guild.rs') diff --git a/src/builder/edit_guild.rs b/src/builder/edit_guild.rs index 45969fe..b15658c 100644 --- a/src/builder/edit_guild.rs +++ b/src/builder/edit_guild.rs @@ -1,5 +1,5 @@ use internal::prelude::*; -use model::{ChannelId, Region, UserId, VerificationLevel}; +use model::prelude::*; use std::collections::HashMap; /// A builder to optionally edit certain fields of a [`Guild`]. This is meant @@ -56,7 +56,7 @@ impl EditGuild { /// from the cwd and encode it in base64 to send to Discord. /// /// ```rust,no_run - /// # use serenity::model::GuildId; + /// # use serenity::model::id::GuildId; /// # use std::error::Error; /// # /// # fn try_main() -> Result<(), Box> { @@ -112,12 +112,12 @@ impl EditGuild { /// Setting the region to [`Region::UsWest`]: /// /// ```rust,no_run - /// # use serenity::model::GuildId; + /// # use serenity::model::id::GuildId; /// # use std::error::Error; /// # /// # fn try_main() -> Result<(), Box> { /// # let mut guild = GuildId(0).get()?; - /// use serenity::model::Region; + /// use serenity::model::guild::Region; /// /// // assuming a `guild` has already been bound /// @@ -163,7 +163,7 @@ impl EditGuild { /// Setting the verification level to [`High`][`VerificationLevel::High`]: /// /// ```rust,ignore - /// use serenity::model::VerificationLevel; + /// use serenity::model::guild::VerificationLevel; /// /// // assuming a `guild` has already been bound /// -- cgit v1.2.3