mithril_common/certificate_chain/
certificate_retriever.rs

1//! A module used to retrieve the Certificate Chain created by an aggregator
2//!
3use async_trait::async_trait;
4use thiserror::Error;
5
6use crate::{entities::Certificate, StdError};
7
8/// [CertificateRetriever] related errors.
9#[derive(Debug, Error)]
10#[error("Error when retrieving certificate")]
11pub struct CertificateRetrieverError(#[source] pub StdError);
12
13/// CertificateRetriever is in charge of retrieving a [Certificate] given its hash
14#[cfg_attr(test, mockall::automock)]
15#[cfg_attr(target_family = "wasm", async_trait(?Send))]
16#[cfg_attr(not(target_family = "wasm"), async_trait)]
17pub trait CertificateRetriever: Sync + Send {
18    /// Get [Certificate] details
19    async fn get_certificate_details(
20        &self,
21        certificate_hash: &str,
22    ) -> Result<Certificate, CertificateRetrieverError>;
23}