diff options
| author | Zeyla Hellyer <[email protected]> | 2017-05-22 17:02:00 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-05-22 17:02:00 -0700 |
| commit | 9969be60cf320797c37b317da24d9a08fd5eafa5 (patch) | |
| tree | f27bf7a57af95bbc11990b1edcea9cca99276964 /src/model/guild/emoji.rs | |
| parent | Reasonably derive Debug on items (diff) | |
| download | serenity-9969be60cf320797c37b317da24d9a08fd5eafa5.tar.xz serenity-9969be60cf320797c37b317da24d9a08fd5eafa5.zip | |
Restructure modules
Modules are now separated into a fashion where the library can be used
for most use cases, without needing to compile the rest.
The core of serenity, with no features enabled, contains only the
struct (model) definitions, constants, and prelude. Models do not have
most functions compiled in, as that is separated into the `model`
feature.
The `client` module has been split into 3 modules: `client`, `gateway`,
and `http`.
`http` contains functions to interact with the REST API. `gateway`
contains the Shard to interact with the gateway, requiring `http` for
retrieving the gateway URL. `client` requires both of the other features
and acts as an abstracted interface over both the gateway and REST APIs,
handling the event loop.
The `builder` module has been separated from `utils`, and can now be
optionally compiled in. It and the `http` feature are required by the
`model` feature due to a large number of methods requiring access to
them.
`utils` now contains a number of utilities, such as the Colour struct, the
`MessageBuilder`, and mention parsing functions.
Each of the original `ext` modules are still featured, with `cache` not
requiring any feature to be enabled, `framework` requiring the `client`,
`model`, and `utils`, and `voice` requiring `gateway`.
In total the features and their requirements are:
- `builder`: none
- `cache`: none
- `client`: `gateway`, `http`
- `framework`: `client`, `model`, `utils`
- `gateway`: `http`
- `http`: none
- `model`: `builder`, `http`
- `utils`: none
- `voice`: `gateway`
The default features are `builder`, `cache`, `client`, `framework`,
`gateway`, `model`, `http`, and `utils`.
To help with forwards compatibility, modules have been re-exported from
their original locations.
Diffstat (limited to 'src/model/guild/emoji.rs')
| -rw-r--r-- | src/model/guild/emoji.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/model/guild/emoji.rs b/src/model/guild/emoji.rs index 4c2b6fc..2de4e30 100644 --- a/src/model/guild/emoji.rs +++ b/src/model/guild/emoji.rs @@ -1,14 +1,16 @@ use std::fmt::{Display, Formatter, Result as FmtResult, Write as FmtWrite}; -use ::model::{EmojiId, RoleId}; +use super::super::{EmojiId, ModelError, RoleId}; #[cfg(feature="cache")] use std::mem; #[cfg(feature="cache")] -use ::client::{CACHE, rest}; +use ::CACHE; #[cfg(feature="cache")] use ::internal::prelude::*; +#[cfg(feature="model")] +use ::http; #[cfg(feature="cache")] -use ::model::GuildId; +use super::super::GuildId; /// Represents a custom guild emoji, which can either be created using the API, /// or via an integration. Emojis created using the API only work within the @@ -34,6 +36,7 @@ pub struct Emoji { pub roles: Vec<RoleId>, } +#[cfg(feature="model")] impl Emoji { /// Deletes the emoji. /// @@ -45,8 +48,8 @@ impl Emoji { #[cfg(feature="cache")] pub fn delete(&self) -> Result<()> { match self.find_guild_id() { - Some(guild_id) => rest::delete_emoji(guild_id.0, self.id.0), - None => Err(Error::Client(ClientError::ItemMissing)), + Some(guild_id) => http::delete_emoji(guild_id.0, self.id.0), + None => Err(Error::Model(ModelError::ItemMissing)), } } @@ -65,7 +68,7 @@ impl Emoji { "name": name, }); - match rest::edit_emoji(guild_id.0, self.id.0, &map) { + match http::edit_emoji(guild_id.0, self.id.0, &map) { Ok(emoji) => { mem::replace(self, emoji); @@ -74,7 +77,7 @@ impl Emoji { Err(why) => Err(why), } }, - None => Err(Error::Client(ClientError::ItemMissing)), + None => Err(Error::Model(ModelError::ItemMissing)), } } |