twilight_cache_inmemory/event/
thread.rs1use crate::{config::ResourceType, CacheableModels, InMemoryCache, UpdateCache};
2use twilight_model::gateway::payload::incoming::{
3 ThreadCreate, ThreadDelete, ThreadListSync, ThreadUpdate,
4};
5
6impl<CacheModels: CacheableModels> UpdateCache<CacheModels> for ThreadCreate {
7 fn update(&self, cache: &InMemoryCache<CacheModels>) {
8 if !cache.wants(ResourceType::CHANNEL) {
9 return;
10 }
11
12 cache.cache_channel(self.0.clone());
13 }
14}
15
16impl<CacheModels: CacheableModels> UpdateCache<CacheModels> for ThreadDelete {
17 fn update(&self, cache: &InMemoryCache<CacheModels>) {
18 if !cache.wants(ResourceType::CHANNEL) {
19 return;
20 }
21
22 cache.delete_channel(self.id);
23 }
24}
25
26impl<CacheModels: CacheableModels> UpdateCache<CacheModels> for ThreadListSync {
27 fn update(&self, cache: &InMemoryCache<CacheModels>) {
28 if !cache.wants(ResourceType::CHANNEL) {
29 return;
30 }
31
32 cache.cache_channels(self.threads.clone());
33 }
34}
35
36impl<CacheModels: CacheableModels> UpdateCache<CacheModels> for ThreadUpdate {
37 fn update(&self, cache: &InMemoryCache<CacheModels>) {
38 if !cache.wants(ResourceType::CHANNEL) {
39 return;
40 }
41
42 cache.cache_channel(self.0.clone());
43 }
44}