aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2016-11-22 07:57:51 -0800
committerAustin Hellyer <[email protected]>2016-11-22 07:57:51 -0800
commitd4726f899cf6b86d805a8a2a77ec57782ec3bdd6 (patch)
tree7966be3c6d6c4284bb618b88b3f146dd412af677 /src/client
parentDon't typo CreateEmbed::image field (diff)
downloadserenity-d4726f899cf6b86d805a8a2a77ec57782ec3bdd6.tar.xz
serenity-d4726f899cf6b86d805a8a2a77ec57782ec3bdd6.zip
Rename the State to Cache
Diffstat (limited to 'src/client')
-rw-r--r--src/client/context.rs56
-rw-r--r--src/client/dispatch.rs66
-rw-r--r--src/client/error.rs10
-rw-r--r--src/client/event_store.rs52
-rw-r--r--src/client/mod.rs60
5 files changed, 122 insertions, 122 deletions
diff --git a/src/client/context.rs b/src/client/context.rs
index 04f08e0..67c0146 100644
--- a/src/client/context.rs
+++ b/src/client/context.rs
@@ -20,8 +20,8 @@ use ::internal::prelude::*;
use ::model::*;
use ::utils;
-#[cfg(feature = "state")]
-use super::STATE;
+#[cfg(feature = "cache")]
+use super::CACHE;
/// The context is a general utility struct provided on event dispatches, which
/// helps with dealing with the current "context" of the event dispatch,
@@ -41,12 +41,12 @@ use super::STATE;
/// A context will only live for the event it was dispatched for. After the
/// event handler finished, it is destroyed and will not be re-used.
///
-/// # Automatically using the State
+/// # Automatically using the Cache
///
-/// The context makes use of the [`State`] being global, and will first check
-/// the state for associated data before hitting the REST API. This is to save
+/// The context makes use of the [`Cache`] being global, and will first check
+/// the cache for associated data before hitting the REST API. This is to save
/// Discord requests, and ultimately save your bot bandwidth and time. This also
-/// acts as a clean interface for retrieving from the state without needing to
+/// acts as a clean interface for retrieving from the cache without needing to
/// check it yourself first, and then performing a request if it does not exist.
/// The context ultimately acts as a means to simplify these two operations into
/// one.
@@ -54,13 +54,13 @@ use super::STATE;
/// For example, if you are needing information about a
/// [channel][`PublicChannel`] within a [guild][`LiveGuild`], then you can
/// use [`get_channel`] to retrieve it. Under most circumstances, the guild and
-/// its channels will be cached within the state, and `get_channel` will just
-/// pull from the state. If it does not exist, it will make a request to the
-/// REST API, and then insert a clone of the channel into the state, returning
+/// its channels will be cached within the cache, and `get_channel` will just
+/// pull from the cache. If it does not exist, it will make a request to the
+/// REST API, and then insert a clone of the channel into the cache, returning
/// you the channel.
///
-/// In this scenario, now that the state has the channel, performing the same
-/// request to `get_channel` will instead pull from the state, as it is now
+/// In this scenario, now that the cache has the channel, performing the same
+/// request to `get_channel` will instead pull from the cache, as it is now
/// cached.
///
/// [`Channel`]: ../model/enum.Channel.html
@@ -69,7 +69,7 @@ use super::STATE;
/// [`Message`]: ../model/struct.Message.html
/// [`PublicChannel`]: ../model/struct.PublicChannel.html
/// [`Shard`]: gateway/struct.Shard.html
-/// [`State`]: ../ext/state/struct.State.html
+/// [`Cache`]: ../ext/cache/struct.Cache.html
/// [`get_channel`]: #method.get_channel
/// [`http`]: http/index.html
/// [`say`]: #method.say
@@ -761,11 +761,11 @@ impl Context {
let guild_id = guild_id.into();
let role_id = role_id.into();
- feature_state! {{
- let state = STATE.lock().unwrap();
+ feature_cache! {{
+ let cache = CACHE.lock().unwrap();
let role = if let Some(role) = {
- state.get_role(guild_id.0, role_id.0)
+ cache.get_role(guild_id.0, role_id.0)
} {
role
} else {
@@ -824,8 +824,8 @@ impl Context {
where C: Into<ChannelId> {
let channel_id = channel_id.into();
- feature_state_enabled! {{
- if let Some(channel) = STATE.lock().unwrap().get_channel(channel_id) {
+ feature_cache_enabled! {{
+ if let Some(channel) = CACHE.lock().unwrap().get_channel(channel_id) {
return Ok(channel.clone());
}
}}
@@ -837,10 +837,10 @@ impl Context {
-> Result<HashMap<ChannelId, PublicChannel>> where G: Into<GuildId> {
let guild_id = guild_id.into();
- feature_state_enabled! {{
- let state = STATE.lock().unwrap();
+ feature_cache_enabled! {{
+ let cache = CACHE.lock().unwrap();
- if let Some(guild) = state.get_guild(guild_id) {
+ if let Some(guild) = cache.get_guild(guild_id) {
return Ok(guild.channels.clone());
}
}}
@@ -902,10 +902,10 @@ impl Context {
let guild_id = guild_id.into();
let user_id = user_id.into();
- feature_state_enabled! {{
- let state = STATE.lock().unwrap();
+ feature_cache_enabled! {{
+ let cache = CACHE.lock().unwrap();
- if let Some(member) = state.get_member(guild_id, user_id) {
+ if let Some(member) = cache.get_member(guild_id, user_id) {
return Ok(member.clone());
}
}}
@@ -1132,7 +1132,7 @@ impl Context {
/// information was generated by them.
///
/// ```rust,no_run
- /// use serenity::client::{STATE, Client, Context};
+ /// use serenity::client::{CACHE, Client, Context};
/// use serenity::model::{Channel, Message};
/// use serenity::utils::Colour;
/// use std::env;
@@ -1149,8 +1149,8 @@ impl Context {
/// let _ = client.start();
///
/// fn ping(context: Context, message: Message, _arguments: Vec<String>) {
- /// let state = STATE.lock().unwrap();
- /// let ch = state.get_channel(message.channel_id);
+ /// let cache = CACHE.lock().unwrap();
+ /// let ch = cache.get_channel(message.channel_id);
/// let name = match ch {
/// Some(Channel::Public(ch)) => ch.name.clone(),
/// _ => "Unknown".to_owned(),
@@ -1181,9 +1181,9 @@ impl Context {
/// .name("Channel name:")
/// .value(&name))
/// .footer(|mut f| {
- /// f = f.text(&format!("Generated by {}", state.user.name));
+ /// f = f.text(&format!("Generated by {}", cache.user.name));
///
- /// if let Some(avatar) = state.user.avatar_url() {
+ /// if let Some(avatar) = cache.user.avatar_url() {
/// f = f.icon_url(&avatar);
/// }
///
diff --git a/src/client/dispatch.rs b/src/client/dispatch.rs
index 96c8e69..b1e593e 100644
--- a/src/client/dispatch.rs
+++ b/src/client/dispatch.rs
@@ -9,8 +9,8 @@ use ::model::{ChannelId, Event, Message};
#[cfg(feature="framework")]
use ::ext::framework::Framework;
-#[cfg(feature = "state")]
-use super::STATE;
+#[cfg(feature = "cache")]
+use super::CACHE;
macro_rules! handler {
($field:ident, $event_store:ident) => {
@@ -24,13 +24,13 @@ macro_rules! handler {
macro_rules! update {
($method:ident, $event:expr) => {
- feature_state_enabled! {{
- STATE.lock().unwrap().$method(&$event)
+ feature_cache_enabled! {{
+ CACHE.lock().unwrap().$method(&$event)
}}
};
($method:ident, $event:expr, $old:expr) => {
- feature_state_enabled! {{
- STATE.lock().unwrap().$method(&$event, $old)
+ feature_cache_enabled! {{
+ CACHE.lock().unwrap().$method(&$event, $old)
}}
};
}
@@ -123,7 +123,7 @@ fn handle_event(event: Event,
let context = context(None, conn, login_type);
let handler = handler.clone();
- feature_state! {{
+ feature_cache! {{
let call = update!(update_with_call_delete, event);
thread::spawn(move || {
@@ -143,9 +143,9 @@ fn handle_event(event: Event,
let context = context(None, conn, login_type);
let handler = handler.clone();
- feature_state! {{
+ feature_cache! {{
let before = update!(update_with_call_update, event, true);
- let after = STATE
+ let after = CACHE
.lock()
.unwrap()
.calls
@@ -161,7 +161,7 @@ fn handle_event(event: Event,
});
}}
} else {
- feature_state_enabled! {{
+ feature_cache_enabled! {{
update!(update_with_call_update, event, false);
}}
}
@@ -253,8 +253,8 @@ fn handle_event(event: Event,
login_type);
let handler = handler.clone();
- feature_state! {{
- let before = STATE.lock()
+ feature_cache! {{
+ let before = CACHE.lock()
.unwrap()
.get_channel(event.channel.id());
update!(update_with_channel_update, event);
@@ -328,7 +328,7 @@ fn handle_event(event: Event,
let context = context(None, conn, login_type);
let handler = handler.clone();
- feature_state! {{
+ feature_cache! {{
let full = update!(update_with_guild_delete, event);
thread::spawn(move || {
@@ -340,7 +340,7 @@ fn handle_event(event: Event,
});
}}
} else {
- feature_state_enabled! {{
+ feature_cache_enabled! {{
let _full = update!(update_with_guild_delete, event);
}}
}
@@ -384,7 +384,7 @@ fn handle_event(event: Event,
let context = context(None, conn, login_type);
let handler = handler.clone();
- feature_state! {{
+ feature_cache! {{
let member = update!(update_with_guild_member_remove, event);
thread::spawn(move || {
@@ -396,7 +396,7 @@ fn handle_event(event: Event,
});
}}
} else {
- feature_state_enabled! {{
+ feature_cache_enabled! {{
let _member = update!(update_with_guild_member_remove, event);
}}
}
@@ -406,13 +406,13 @@ fn handle_event(event: Event,
let context = context(None, conn, login_type);
let handler = handler.clone();
- feature_state! {{
+ feature_cache! {{
let before = update!(update_with_guild_member_update, event);
// This is safe, as the update would have created the member
// if it did not exist. Thus, there _should_ be no way that this
// could fail under any circumstance.
- let after = STATE.lock()
+ let after = CACHE.lock()
.unwrap()
.get_member(event.guild_id, event.user.id)
.unwrap()
@@ -459,7 +459,7 @@ fn handle_event(event: Event,
let context = context(None, conn, login_type);
let handler = handler.clone();
- feature_state! {{
+ feature_cache! {{
let role = update!(update_with_guild_role_delete, event);
thread::spawn(move || {
@@ -471,7 +471,7 @@ fn handle_event(event: Event,
});
}}
} else {
- feature_state_enabled! {{
+ feature_cache_enabled! {{
let _role = update!(update_with_guild_role_delete, event);
}}
}
@@ -481,7 +481,7 @@ fn handle_event(event: Event,
let context = context(None, conn, login_type);
let handler = handler.clone();
- feature_state! {{
+ feature_cache! {{
let before = update!(update_with_guild_role_update, event);
thread::spawn(move || {
@@ -493,7 +493,7 @@ fn handle_event(event: Event,
});
}}
} else {
- feature_state_enabled! {{
+ feature_cache_enabled! {{
let _before = update!(update_with_guild_role_update, event);
}}
}
@@ -525,8 +525,8 @@ fn handle_event(event: Event,
let context = context(None, conn, login_type);
let handler = handler.clone();
- feature_state! {{
- let before = STATE.lock()
+ feature_cache! {{
+ let before = CACHE.lock()
.unwrap()
.guilds
.get(&event.guild.id)
@@ -730,7 +730,7 @@ fn handle_event(event: Event,
let context = context(None, conn, login_type);
let handler = handler.clone();
- feature_state! {{
+ feature_cache! {{
let before = update!(update_with_user_guild_settings_update, event);
thread::spawn(move || {
@@ -742,7 +742,7 @@ fn handle_event(event: Event,
});
}}
} else {
- feature_state_enabled! {{
+ feature_cache_enabled! {{
let _before = update!(update_with_user_guild_settings_update, event);
}}
}
@@ -752,7 +752,7 @@ fn handle_event(event: Event,
let context = context(None, conn, login_type);
let handler = handler.clone();
- feature_state! {{
+ feature_cache! {{
let before = update!(update_with_user_note_update, event);
thread::spawn(move || {
@@ -764,7 +764,7 @@ fn handle_event(event: Event,
});
}}
} else {
- feature_state_enabled! {{
+ feature_cache_enabled! {{
let _before = update!(update_with_user_note_update, event);
}}
}
@@ -774,9 +774,9 @@ fn handle_event(event: Event,
let context = context(None, conn, login_type);
let handler = handler.clone();
- feature_state! {{
+ feature_cache! {{
let before = update!(update_with_user_settings_update, event, true);
- let after = STATE.lock().unwrap().settings.clone();
+ let after = CACHE.lock().unwrap().settings.clone();
thread::spawn(move || {
(handler)(context, before.unwrap(), after.unwrap());
@@ -787,7 +787,7 @@ fn handle_event(event: Event,
});
}}
} else {
- feature_state_enabled! {{
+ feature_cache_enabled! {{
update!(update_with_user_settings_update, event, false);
}}
}
@@ -797,7 +797,7 @@ fn handle_event(event: Event,
let context = context(None, conn, login_type);
let handler = handler.clone();
- feature_state! {{
+ feature_cache! {{
let before = update!(update_with_user_update, event);
thread::spawn(move || {
@@ -809,7 +809,7 @@ fn handle_event(event: Event,
});
}}
} else {
- feature_state_enabled! {{
+ feature_cache_enabled! {{
let _before = update!(update_with_user_update, event);
}}
}
diff --git a/src/client/error.rs b/src/client/error.rs
index 9b542ec..a016e92 100644
--- a/src/client/error.rs
+++ b/src/client/error.rs
@@ -60,11 +60,11 @@ pub enum Error {
/// When there was an error retrieving the gateway URI from the REST API.
Gateway,
/// An indication that a [guild][`LiveGuild`] could not be found by
- /// [Id][`GuildId`] in the [`State`].
+ /// [Id][`GuildId`] in the [`Cache`].
///
/// [`GuildId`]: ../model/struct.GuildId.html
/// [`LiveGuild`]: ../model/struct.LiveGuild.html
- /// [`State`]: ../ext/state/struct.State.html
+ /// [`Cache`]: ../ext/cache/struct.Cache.html
GuildNotFound,
InvalidOpCode,
/// When attempting to perform an action which is only available to user
@@ -92,10 +92,10 @@ pub enum Error {
///
/// [current user]: ../model/struct.CurrentUser.html
InvalidUser,
- /// An indicator that an item is missing from the [`State`], and the action
+ /// An indicator that an item is missing from the [`Cache`], and the action
/// can not be continued.
///
- /// [`State`]: ../ext/state/struct.State.html
+ /// [`Cache`]: ../ext/cache/struct.Cache.html
ItemMissing,
/// Indicates that a [`Message`]s content was too long and will not
/// successfully send, as the length is over 2000 codepoints, or 4000 bytes.
@@ -117,7 +117,7 @@ pub enum Error {
/// When the decoding of a ratelimit header could not be properly decoded
/// from UTF-8.
RateLimitUtf8,
- /// When attempting to find a required record from the State could not be
+ /// When attempting to find a required record from the Cache could not be
/// found. This is required in methods such as [`Context::edit_role`].
///
/// [`Context::edit_role`]: struct.Context.html#method.edit_role
diff --git a/src/client/event_store.rs b/src/client/event_store.rs
index 9558ba1..0deaa94 100644
--- a/src/client/event_store.rs
+++ b/src/client/event_store.rs
@@ -26,13 +26,13 @@ use ::model::*;
#[derive(Default)]
pub struct EventStore {
pub on_call_create: Option<Arc<Fn(Context, Call) + Send + Sync + 'static>>,
- #[cfg(feature = "state")]
+ #[cfg(feature = "cache")]
pub on_call_delete: Option<Arc<Fn(Context, ChannelId, Option<Call>) + Send + Sync + 'static>>,
- #[cfg(not(feature = "state"))]
+ #[cfg(not(feature = "cache"))]
pub on_call_delete: Option<Arc<Fn(Context, ChannelId) + Send + Sync + 'static>>,
- #[cfg(feature = "state")]
+ #[cfg(feature = "cache")]
pub on_call_update: Option<Arc<Fn(Context, Option<Call>, Option<Call>) + Send + Sync + 'static>>,
- #[cfg(not(feature = "state"))]
+ #[cfg(not(feature = "cache"))]
pub on_call_update: Option<Arc<Fn(Context, CallUpdateEvent) + Send + Sync + 'static>>,
pub on_channel_create: Option<Arc<Fn(Context, Channel) + Send + Sync + 'static>>,
pub on_channel_delete: Option<Arc<Fn(Context, Channel) + Send + Sync + 'static>>,
@@ -40,45 +40,45 @@ pub struct EventStore {
pub on_channel_pins_update: Option<Arc<Fn(Context, ChannelPinsUpdateEvent) + Send + Sync + 'static>>,
pub on_channel_recipient_addition: Option<Arc<Fn(Context, ChannelId, User) + Send + Sync + 'static>>,
pub on_channel_recipient_removal: Option<Arc<Fn(Context, ChannelId, User) + Send + Sync + 'static>>,
- #[cfg(feature = "state")]
+ #[cfg(feature = "cache")]
pub on_channel_update: Option<Arc<Fn(Context, Option<Channel>, Channel) + Send + Sync + 'static>>,
- #[cfg(not(feature = "state"))]
+ #[cfg(not(feature = "cache"))]
pub on_channel_update: Option<Arc<Fn(Context, Channel) + Send + Sync + 'static>>,
pub on_friend_suggestion_create: Option<Arc<Fn(Context, User, Vec<SuggestionReason>) + Send + Sync + 'static>>,
pub on_friend_suggestion_delete: Option<Arc<Fn(Context, UserId) + Send + Sync + 'static>>,
pub on_guild_ban_addition: Option<Arc<Fn(Context, GuildId, User) + Send + Sync + 'static>>,
pub on_guild_ban_removal: Option<Arc<Fn(Context, GuildId, User) + Send + Sync + 'static>>,
pub on_guild_create: Option<Arc<Fn(Context, LiveGuild) + Send + Sync + 'static>>,
- #[cfg(feature = "state")]
+ #[cfg(feature = "cache")]
pub on_guild_delete: Option<Arc<Fn(Context, Guild, Option<LiveGuild>) + Send + Sync + 'static>>,
- #[cfg(not(feature = "state"))]
+ #[cfg(not(feature = "cache"))]
pub on_guild_delete: Option<Arc<Fn(Context, Guild) + Send + Sync + 'static>>,
pub on_guild_emojis_update: Option<Arc<Fn(Context, GuildId, HashMap<EmojiId, Emoji>) + Send + Sync + 'static>>,
pub on_guild_integrations_update: Option<Arc<Fn(Context, GuildId) + Send + Sync + 'static>>,
pub on_guild_member_addition: Option<Arc<Fn(Context, GuildId, Member) + Send + Sync + 'static>>,
- #[cfg(feature = "state")]
+ #[cfg(feature = "cache")]
pub on_guild_member_removal: Option<Arc<Fn(Context, GuildId, User, Option<Member>) + Send + Sync + 'static>>,
- #[cfg(not(feature = "state"))]
+ #[cfg(not(feature = "cache"))]
pub on_guild_member_removal: Option<Arc<Fn(Context, GuildId, User) + Send + Sync + 'static>>,
- #[cfg(feature = "state")]
+ #[cfg(feature = "cache")]
pub on_guild_member_update: Option<Arc<Fn(Context, Option<Member>, Member) + Send + Sync + 'static>>,
- #[cfg(not(feature = "state"))]
+ #[cfg(not(feature = "cache"))]
pub on_guild_member_update: Option<Arc<Fn(Context, GuildMemberUpdateEvent) + Send + Sync + 'static>>,
pub on_guild_members_chunk: Option<Arc<Fn(Context, GuildId, HashMap<UserId, Member>) + Send + Sync + 'static>>,
pub on_guild_role_create: Option<Arc<Fn(Context, GuildId, Role) + Send + Sync + 'static>>,
- #[cfg(feature = "state")]
+ #[cfg(feature = "cache")]
pub on_guild_role_delete: Option<Arc<Fn(Context, GuildId, RoleId, Option<Role>) + Send + Sync + 'static>>,
- #[cfg(not(feature = "state"))]
+ #[cfg(not(feature = "cache"))]
pub on_guild_role_delete: Option<Arc<Fn(Context, GuildId, RoleId) + Send + Sync + 'static>>,
- #[cfg(feature = "state")]
+ #[cfg(feature = "cache")]
pub on_guild_role_update: Option<Arc<Fn(Context, GuildId, Option<Role>, Role) + Send + Sync + 'static>>,
- #[cfg(not(feature = "state"))]
+ #[cfg(not(feature = "cache"))]
pub on_guild_role_update: Option<Arc<Fn(Context, GuildId, Role) + Send + Sync + 'static>>,
pub on_guild_sync: Option<Arc<Fn(Context, GuildSyncEvent) + Send + Sync + 'static>>,
pub on_guild_unavailable: Option<Arc<Fn(Context, GuildId) + Send + Sync + 'static>>,
- #[cfg(feature = "state")]
+ #[cfg(feature = "cache")]
pub on_guild_update: Option<Arc<Fn(Context, Option<LiveGuild>, Guild) + Send + Sync + 'static>>,
- #[cfg(not(feature = "state"))]
+ #[cfg(not(feature = "cache"))]
pub on_guild_update: Option<Arc<Fn(Context, Guild) + Send + Sync + 'static>>,
pub on_message: Option<Arc<Fn(Context, Message) + Send + Sync + 'static>>,
pub on_message_ack: Option<Arc<Fn(Context, ChannelId, Option<MessageId>) + Send + Sync + 'static>>,
@@ -88,9 +88,9 @@ pub struct EventStore {
pub on_reaction_remove: Option<Arc<Fn(Context, Reaction) + Send + Sync + 'static>>,
pub on_reaction_remove_all: Option<Arc<Fn(Context, ChannelId, MessageId) + Send + Sync + 'static>>,
pub on_message_update: Option<Arc<Fn(Context, MessageUpdateEvent) + Send + Sync + 'static>>,
- #[cfg(feature = "state")]
+ #[cfg(feature = "cache")]
pub on_note_update: Option<Arc<Fn(Context, UserId, Option<String>, String) + Send + Sync + 'static>>,
- #[cfg(not(feature = "state"))]
+ #[cfg(not(feature = "cache"))]
pub on_note_update: Option<Arc<Fn(Context, UserId, String) + Send + Sync + 'static>>,
pub on_presence_replace: Option<Arc<Fn(Context, Vec<Presence>) + Send + Sync + 'static>>,
pub on_presence_update: Option<Arc<Fn(Context, PresenceUpdateEvent) + Send + Sync + 'static>>,
@@ -100,17 +100,17 @@ pub struct EventStore {
pub on_resume: Option<Arc<Fn(Context, ResumedEvent) + Send + Sync + 'static>>,
pub on_typing_start: Option<Arc<Fn(Context, TypingStartEvent) + Send + Sync + 'static>>,
pub on_unknown: Option<Arc<Fn(Context, String, BTreeMap<String, Value>) + Send + Sync + 'static>>,
- #[cfg(feature = "state")]
+ #[cfg(feature = "cache")]
pub on_user_guild_settings_update: Option<Arc<Fn(Context, Option<UserGuildSettings>, UserGuildSettings) + Send + Sync + 'static>>,
- #[cfg(not(feature = "state"))]
+ #[cfg(not(feature = "cache"))]
pub on_user_guild_settings_update: Option<Arc<Fn(Context, UserGuildSettings) + Send + Sync + 'static>>,
- #[cfg(feature = "state")]
+ #[cfg(feature = "cache")]
pub on_user_update: Option<Arc<Fn(Context, CurrentUser, CurrentUser) + Send + Sync + 'static>>,
- #[cfg(not(feature = "state"))]
+ #[cfg(not(feature = "cache"))]
pub on_user_update: Option<Arc<Fn(Context, CurrentUser) + Send + Sync + 'static>>,
- #[cfg(feature = "state")]
+ #[cfg(feature = "cache")]
pub on_user_settings_update: Option<Arc<Fn(Context, UserSettings, UserSettings) + Send + Sync + 'static>>,
- #[cfg(not(feature = "state"))]
+ #[cfg(not(feature = "cache"))]
pub on_user_settings_update: Option<Arc<Fn(Context, UserSettingsUpdateEvent) + Send + Sync + 'static>>,
pub on_voice_server_update: Option<Arc<Fn(Context, VoiceServerUpdateEvent) + Send + Sync + 'static>>,
pub on_voice_state_update: Option<Arc<Fn(Context, Option<GuildId>, VoiceState) + Send + Sync + 'static>>,
diff --git a/src/client/mod.rs b/src/client/mod.rs
index d9c3ce2..2a9793f 100644
--- a/src/client/mod.rs
+++ b/src/client/mod.rs
@@ -1,7 +1,7 @@
//! The Client contains information about a single bot or user's token, as well
//! as event handlers. Dispatching events to configured handlers and starting
//! the shards' connections are handled directly via the client. In addition,
-//! the [`http`] module and [`State`] are also automatically handled by the
+//! the [`http`] module and [`Cache`] are also automatically handled by the
//! Client module for you.
//!
//! A [`Context`] is provided for every handler. The context is an ergonomic
@@ -10,14 +10,14 @@
//! The `http` module is the lower-level method of interacting with the Discord
//! REST API. Realistically, there should be little reason to use this yourself,
//! as the Context will do this for you. A possible use case of using the `http`
-//! module is if you do not have a State, for purposes such as low memory
+//! module is if you do not have a Cache, for purposes such as low memory
//! requirements.
//!
//! Click [here][Client examples] for an example on how to use a `Client`.
//!
//! [`Client`]: struct.Client.html#examples
//! [`Context`]: struct.Context.html
-//! [`State`]: ../ext/state/index.html
+//! [`Cache`]: ../ext/cache/index.html
//! [`http`]: http/index.html
//! [Client examples]: struct.Client.html#examples
@@ -51,33 +51,33 @@ use ::model::*;
#[cfg(feature = "framework")]
use ::ext::framework::Framework;
-#[cfg(feature = "state")]
-use ::ext::state::State;
+#[cfg(feature = "cache")]
+use ::ext::cache::Cache;
-#[cfg(feature = "state")]
+#[cfg(feature = "cache")]
lazy_static! {
- /// The STATE is a mutable lazily-initialized static binding. It can be
+ /// The CACHE is a mutable lazily-initialized static binding. It can be
/// accessed across any function and in any context.
///
- /// This [`State`] instance is updated for every event received, so you do
- /// not need to maintain your own state.
+ /// This [`Cache`] instance is updated for every event received, so you do
+ /// not need to maintain your own cache.
///
- /// See the [state module documentation] for more details.
+ /// See the [cache module documentation] for more details.
///
/// # Examples
///
/// Retrieve the [current user][`CurrentUser`]'s Id:
///
/// ```rust,ignore
- /// use serenity::client::STATE;
+ /// use serenity::client::CACHE;
///
- /// println!("{}", STATE.lock().unwrap().user.id);
+ /// println!("{}", CACHE.lock().unwrap().user.id);
/// ```
///
/// [`CurrentUser`]: ../model/struct.CurrentUser.html
- /// [`State`]: ../ext/state/struct.State.html
- /// [state module documentation]: ../ext/state/index.html
- pub static ref STATE: Arc<Mutex<State>> = Arc::new(Mutex::new(State::default()));
+ /// [`Cache`]: ../ext/cache/struct.Cache.html
+ /// [cache module documentation]: ../ext/cache/index.html
+ pub static ref CACHE: Arc<Mutex<Cache>> = Arc::new(Mutex::new(Cache::default()));
}
/// The Client is the way to "login" and be able to start sending authenticated
@@ -729,8 +729,8 @@ impl Client {
Ok((shard, ready, receiver)) => {
self.shards.push(Arc::new(Mutex::new(shard)));
- feature_state_enabled! {{
- STATE.lock()
+ feature_cache_enabled! {{
+ CACHE.lock()
.unwrap()
.update_with_ready(&ready);
}}
@@ -801,12 +801,12 @@ impl Client {
}
}
-#[cfg(feature = "state")]
+#[cfg(feature = "cache")]
impl Client {
/// Attaches a handler for when a [`CallDelete`] is received.
///
/// The `ChannelId` is the Id of the channel hosting the call. Returns the
- /// call from the state - optionally - if the call was in it.
+ /// call from the cache - optionally - if the call was in it.
///
/// [`CallDelete`]: ../model/enum.Event.html#variant.CallDelete
pub fn on_call_delete<F>(&mut self, handler: F)
@@ -842,15 +842,15 @@ impl Client {
///
/// Returns a partial guild as well as - optionally - the full guild, with
/// data like [`Role`]s. This can be `None` in the event that it was not in
- /// the [`State`].
+ /// the [`Cache`].
///
- /// **Note**: The relevant guild is _removed_ from the State when this event
+ /// **Note**: The relevant guild is _removed_ from the Cache when this event
/// is received. If you need to keep it, you can either re-insert it
- /// yourself back into the State or manage it in another way.
+ /// yourself back into the Cache or manage it in another way.
///
/// [`GuildDelete`]: ../model/enum.Event.html#variant.GuildDelete
/// [`Role`]: ../model/struct.Role.html
- /// [`State`]: ../ext/state/struct.State.html
+ /// [`Cache`]: ../ext/cache/struct.Cache.html
pub fn on_guild_delete<F>(&mut self, handler: F)
where F: Fn(Context, Guild, Option<LiveGuild>) + Send + Sync + 'static {
self.event_store.lock()
@@ -861,7 +861,7 @@ impl Client {
/// Attaches a handler for when a [`GuildMemberRemove`] is received.
///
/// Returns the user's associated `Member` object, _if_ it existed in the
- /// state.
+ /// cache.
///
/// [`GuildMemberRemove`]: ../model/enum.Event.html#variant.GuildMemberRemove
pub fn on_guild_member_remove<F>(&mut self, handler: F)
@@ -894,10 +894,10 @@ impl Client {
/// Attaches a handler for when a [`GuildRoleUpdate`] is received.
///
/// The optional `Role` is the role prior to updating. This can be `None` if
- /// it did not exist in the [`State`] before the update.
+ /// it did not exist in the [`Cache`] before the update.
///
/// [`GuildRoleUpdate`]: ../model/enum.Event.html#variant.GuildRoleUpdate
- /// [`State`]: ../ext/state/struct.State.html
+ /// [`Cache`]: ../ext/cache/struct.Cache.html
pub fn on_guild_role_update<F>(&mut self, handler: F)
where F: Fn(Context, GuildId, Option<Role>, Role) + Send + Sync + 'static {
self.event_store.lock()
@@ -963,7 +963,7 @@ impl Client {
}
}
-#[cfg(not(feature = "state"))]
+#[cfg(not(feature = "cache"))]
impl Client {
/// Attaches a handler for when a [`CallDelete`] is received.
///
@@ -999,7 +999,7 @@ impl Client {
///
/// [`GuildDelete`]: ../model/enum.Event.html#variant.GuildDelete
/// [`Role`]: ../model/struct.Role.html
- /// [`State`]: ../ext/state/struct.State.html
+ /// [`Cache`]: ../ext/cache/struct.Cache.html
pub fn on_guild_delete<F>(&mut self, handler: F)
where F: Fn(Context, Guild) + Send + Sync + 'static {
self.event_store.lock()
@@ -1010,7 +1010,7 @@ impl Client {
/// Attaches a handler for when a [`GuildMemberRemove`] is received.
///
/// Returns the user's associated `Member` object, _if_ it existed in the
- /// state.
+ /// cache.
///
/// [`GuildMemberRemove`]: ../model/enum.Event.html#variant.GuildMemberRemove
pub fn on_guild_member_remove<F>(&mut self, handler: F)
@@ -1043,7 +1043,7 @@ impl Client {
/// Attaches a handler for when a [`GuildRoleUpdate`] is received.
///
/// [`GuildRoleUpdate`]: ../model/enum.Event.html#variant.GuildRoleUpdate
- /// [`State`]: ../ext/state/struct.State.html
+ /// [`Cache`]: ../ext/cache/struct.Cache.html
pub fn on_guild_role_update<F>(&mut self, handler: F)
where F: Fn(Context, GuildId, Role) + Send + Sync + 'static {
self.event_store.lock()