1use crate::{AccountCache, CertCache};
2use async_trait::async_trait;
3use std::convert::Infallible;
4use std::fmt::Debug;
5use std::marker::PhantomData;
6use std::sync::atomic::AtomicPtr;
7
8#[derive(Copy, Clone)]
16pub struct NoCache<EC: Debug = Infallible, EA: Debug = Infallible> {
17 _cert_error: PhantomData<AtomicPtr<Box<EC>>>,
18 _account_error: PhantomData<AtomicPtr<Box<EA>>>,
19}
20
21impl<EC: Debug, EA: Debug> Default for NoCache<EC, EA> {
22 fn default() -> Self {
23 Self {
24 _cert_error: Default::default(),
25 _account_error: Default::default(),
26 }
27 }
28}
29
30#[async_trait]
31impl<EC: Debug, EA: Debug> CertCache for NoCache<EC, EA> {
32 type EC = EC;
33 async fn load_cert(&self, _domains: &[String], _directory_url: &str) -> Result<Option<Vec<u8>>, Self::EC> {
34 log::info!("no cert cache configured, could not load certificate");
35 Ok(None)
36 }
37 async fn store_cert(&self, _domains: &[String], _directory_url: &str, _cert: &[u8]) -> Result<(), Self::EC> {
38 log::info!("no cert cache configured, could not store certificate");
39 Ok(())
40 }
41}
42
43#[async_trait]
44impl<EC: Debug, EA: Debug> AccountCache for NoCache<EC, EA> {
45 type EA = EA;
46 async fn load_account(&self, _contact: &[String], _directory_url: &str) -> Result<Option<Vec<u8>>, Self::EA> {
47 log::info!("no account cache configured, could not load account");
48 Ok(None)
49 }
50 async fn store_account(&self, _contact: &[String], _directory_url: &str, _account: &[u8]) -> Result<(), Self::EA> {
51 log::info!("no account cache configured, could not store account");
52 Ok(())
53 }
54}