diff options
| author | Austin Hellyer <[email protected]> | 2016-11-22 07:57:51 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-22 07:57:51 -0800 |
| commit | d4726f899cf6b86d805a8a2a77ec57782ec3bdd6 (patch) | |
| tree | 7966be3c6d6c4284bb618b88b3f146dd412af677 /src/ext | |
| parent | Don't typo CreateEmbed::image field (diff) | |
| download | serenity-d4726f899cf6b86d805a8a2a77ec57782ec3bdd6.tar.xz serenity-d4726f899cf6b86d805a8a2a77ec57782ec3bdd6.zip | |
Rename the State to Cache
Diffstat (limited to 'src/ext')
| -rw-r--r-- | src/ext/cache/mod.rs (renamed from src/ext/state/mod.rs) | 22 | ||||
| -rw-r--r-- | src/ext/mod.rs | 6 | ||||
| -rw-r--r-- | src/ext/voice/connection.rs | 4 |
3 files changed, 16 insertions, 16 deletions
diff --git a/src/ext/state/mod.rs b/src/ext/cache/mod.rs index 637729c..484de1f 100644 --- a/src/ext/state/mod.rs +++ b/src/ext/cache/mod.rs @@ -4,7 +4,7 @@ use std::default::Default; use std::mem; use ::model::*; -/// A state of all events received over a [`Connection`], where storing at least +/// A cache of all events received over a [`Connection`], where storing at least /// some data from the event is possible. /// /// This acts as a cache, to avoid making requests over the REST API through the @@ -15,14 +15,14 @@ use ::model::*; /// /// # Use by the Context /// -/// The [`Context`] will automatically attempt to pull from the state for you. +/// The [`Context`] will automatically attempt to pull from the cache for you. /// For example, the [`Context::get_channel`] method will attempt to find the -/// channel in the state. If it can not find it, it will perform a request +/// channel in the cache. If it can not find it, it will perform a request /// through the REST API, and then insert a clone of the channel - if found - -/// into the State. +/// into the Cache. /// /// This allows you to only need to perform the `Context::get_channel` call, -/// and not need to first search through the state - and if not found - _then_ +/// and not need to first search through the cache - and if not found - _then_ /// perform an HTTP request through the Context or `http` module. /// /// Additionally, note that some information received through events can _not_ @@ -36,7 +36,7 @@ use ::model::*; /// [`Role`]: ../../model/struct.Role.html /// [`http`]: ../../client/http/index.html #[derive(Debug, Clone)] -pub struct State { +pub struct Cache { /// A map of the currently active calls that the current user knows about, /// where the key is the Id of the [`PrivateChannel`] or [`Group`] hosting /// the call. @@ -65,7 +65,7 @@ pub struct State { pub user: CurrentUser, } -impl State { +impl Cache { pub fn unknown_members(&self) -> u64 { let mut total = 0; @@ -156,7 +156,7 @@ impl State { } } - /// Update the state according to the changes described in the given event. + /// Update the cache according to the changes described in the given event. #[allow(cyclomatic_complexity)] #[allow(unneeded_field_pattern)] pub fn update(&mut self, event: &Event) { @@ -789,9 +789,9 @@ impl State { } } -impl Default for State { - fn default() -> State { - State { +impl Default for Cache { + fn default() -> Cache { + Cache { calls: HashMap::default(), groups: HashMap::default(), guild_settings: HashMap::default(), diff --git a/src/ext/mod.rs b/src/ext/mod.rs index 312074b..4484b0b 100644 --- a/src/ext/mod.rs +++ b/src/ext/mod.rs @@ -6,16 +6,16 @@ //! See each extension's module-level documentation for more information. //! //! Note that the framework module requires the `framework` feature to be -//! enabled (enabled by default), the state requires the `state` feature to be +//! enabled (enabled by default), the cache requires the `cache` feature to be //! enabled (enabled by default), and voice support requires the `voice` feature //! to be enabled (disabled by default). //! //! [`Client`]: ../client/struct.Client.html //! [`Connection`]: ../client/struct.Connection.html +#[cfg(feature = "cache")] +pub mod cache; #[cfg(feature = "framework")] pub mod framework; -#[cfg(feature = "state")] -pub mod state; #[cfg(feature = "voice")] pub mod voice; diff --git a/src/ext/voice/connection.rs b/src/ext/voice/connection.rs index 7dfc034..66c8641 100644 --- a/src/ext/voice/connection.rs +++ b/src/ext/voice/connection.rs @@ -14,7 +14,7 @@ use websocket::client::{ Sender as WsSender }; use websocket::stream::WebSocketStream; -use ::client::STATE; +use ::client::CACHE; use ::constants::VoiceOpCode; use ::internal::prelude::*; use ::internal::ws_impl::{ReceiverExt, SenderExt}; @@ -210,7 +210,7 @@ fn identify(info: &ConnectionInfo) -> Value { .insert("server_id", info.server_id) .insert("session_id", &info.session_id) .insert("token", &info.token) - .insert("user_id", STATE.lock().unwrap().user.id.0)) + .insert("user_id", CACHE.lock().unwrap().user.id.0)) .build() } |