diff options
| author | Lakelezz <[email protected]> | 2018-10-30 15:10:10 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-10-30 15:10:10 +0100 |
| commit | 867a744720c46c0b04a2d34c2119ad366aa440ef (patch) | |
| tree | ab9fd0708f2c4bafe3c554991bb2509c01f898ae /src/model/channel | |
| parent | Fix cache write lock timer (#423) (diff) | |
| download | serenity-867a744720c46c0b04a2d34c2119ad366aa440ef.tar.xz serenity-867a744720c46c0b04a2d34c2119ad366aa440ef.zip | |
Add Function to neutralise Mentions (#414)
Diffstat (limited to 'src/model/channel')
| -rw-r--r-- | src/model/channel/channel_id.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/model/channel/channel_id.rs b/src/model/channel/channel_id.rs index a897002..3f52055 100644 --- a/src/model/channel/channel_id.rs +++ b/src/model/channel/channel_id.rs @@ -14,6 +14,8 @@ use builder::{ }; #[cfg(all(feature = "cache", feature = "model"))] use CACHE; +#[cfg(all(feature = "cache", feature = "model"))] +use Cache; #[cfg(feature = "model")] use http::{self, AttachmentType}; #[cfg(feature = "model")] @@ -293,7 +295,17 @@ impl ChannelId { /// [`Channel`]: ../channel/enum.Channel.html #[cfg(feature = "cache")] #[inline] - pub fn to_channel_cached(self) -> Option<Channel> { CACHE.read().channel(self) } + pub fn to_channel_cached(self) -> Option<Channel> { + self._to_channel_cached(&CACHE) + } + + /// To allow testing pass their own cache instead of using the globale one. + #[cfg(feature = "cache")] + #[inline] + pub(crate) fn _to_channel_cached(self, cache: &RwLock<Cache>) -> Option<Channel> { + cache.read().channel(self) + } + /// Search the cache for the channel. If it can't be found, the channel is /// requested over REST. |