tokio_rustls_acme/caches/
no.rs1use 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
30impl<EC: Debug, EA: Debug> NoCache<EC, EA> {
31 pub fn new() -> Self {
32 Self::default()
33 }
34}
35
36#[async_trait]
37impl<EC: Debug, EA: Debug> CertCache for NoCache<EC, EA> {
38 type EC = EC;
39 async fn load_cert(
40 &self,
41 _domains: &[String],
42 _directory_url: &str,
43 ) -> Result<Option<Vec<u8>>, Self::EC> {
44 log::info!("no cert cache configured, could not load certificate");
45 Ok(None)
46 }
47 async fn store_cert(
48 &self,
49 _domains: &[String],
50 _directory_url: &str,
51 _cert: &[u8],
52 ) -> Result<(), Self::EC> {
53 log::info!("no cert cache configured, could not store certificate");
54 Ok(())
55 }
56}
57
58#[async_trait]
59impl<EC: Debug, EA: Debug> AccountCache for NoCache<EC, EA> {
60 type EA = EA;
61 async fn load_account(
62 &self,
63 _contact: &[String],
64 _directory_url: &str,
65 ) -> Result<Option<Vec<u8>>, Self::EA> {
66 log::info!("no account cache configured, could not load account");
67 Ok(None)
68 }
69 async fn store_account(
70 &self,
71 _contact: &[String],
72 _directory_url: &str,
73 _account: &[u8],
74 ) -> Result<(), Self::EA> {
75 log::info!("no account cache configured, could not store account");
76 Ok(())
77 }
78}