aboutsummaryrefslogtreecommitdiff
path: root/src/model/channel
diff options
context:
space:
mode:
authorLakelezz <[email protected]>2018-10-30 15:10:10 +0100
committerGitHub <[email protected]>2018-10-30 15:10:10 +0100
commit867a744720c46c0b04a2d34c2119ad366aa440ef (patch)
treeab9fd0708f2c4bafe3c554991bb2509c01f898ae /src/model/channel
parentFix cache write lock timer (#423) (diff)
downloadserenity-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.rs14
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.