tetrio_api/http/caches/
noop_cache.rs

1use std::{convert::Infallible, fmt::Debug};
2
3use async_trait::async_trait;
4use serde::{de::DeserializeOwned, Serialize};
5
6use crate::{http::error::Error, models::packet::{Packet, SuccessPacket}};
7
8use super::cache::CacheHandler;
9
10/// A simple cache implementation that simply always does nothing.
11pub struct NoopCache;
12
13#[async_trait]
14impl<ErrorT: std::error::Error + Sync + Send + Debug> CacheHandler<ErrorT> for NoopCache {
15    type CachingError = Infallible;
16    async fn try_get_cache<T: DeserializeOwned + Serialize>(&self, _: &str) -> Result<Option<Packet<T>>, Error<ErrorT, Self::CachingError>>
17    {
18        Ok(None)
19    }
20
21
22    async fn cache_value<T: DeserializeOwned + Serialize + Send + Sync>(&self, _: &str, _: SuccessPacket<T>) -> Result<(), Error<ErrorT, Self::CachingError>> {
23        Ok(())
24    }
25
26}