diff options
Diffstat (limited to 'src/cache/mod.rs')
| -rw-r--r-- | src/cache/mod.rs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/cache/mod.rs b/src/cache/mod.rs index e0a5ee6..3bf5a5a 100644 --- a/src/cache/mod.rs +++ b/src/cache/mod.rs @@ -56,7 +56,7 @@ use std::{ mod cache_update; -pub(crate) use self::cache_update::*; +pub use self::cache_update::CacheUpdate; /// A cache of all events received over a [`Shard`], where storing at least /// some data from the event is possible. @@ -163,6 +163,12 @@ pub struct Cache { } impl Cache { + /// Creates a new cache. + #[inline] + pub fn new() -> Self { + Self::default() + } + /// Fetches the number of [`Member`]s that have not had data received. /// /// The important detail to note here is that this is the number of @@ -664,8 +670,18 @@ impl Cache { self.categories.get(&channel_id).cloned() } - #[cfg(feature = "client")] - pub(crate) fn update<E: CacheUpdate>(&mut self, e: &mut E) -> Option<E::Output> { + /// Updates the cache with the update implementation for an event or other + /// custom update implementation. + /// + /// Refer to the documentation for [`CacheUpdate`] for more information. + /// + /// # Examples + /// + /// Refer to the [`CacheUpdate` examples]. + /// + /// [`CacheUpdate`]: trait.CacheUpdate.html + /// [`CacheUpdate` examples]: trait.CacheUpdate.html#examples + pub fn update<E: CacheUpdate>(&mut self, e: &mut E) -> Option<E::Output> { e.update(self) } |