spiffe/bundle/mod.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
//! X.509 bundle and JWT bundle types.
use crate::spiffe_id::TrustDomain;
use std::error::Error;
pub mod jwt;
pub mod x509;
/// Represents a collection of public keys.
pub trait Bundle {}
/// Represents a source of bundles queryable by [`TrustDomain`].
pub trait BundleRefSource {
/// The type of the bundles provided by the source.
type Item: Bundle;
/// Returns the reference to bundle (set of public keys authorities) associated to the [`TrustDomain`].
/// If it cannot be found a bundle associated to the trust domain, it returns `Ok(None)`.
/// If there's is an error in source fetching the bundle, it returns an `Err<Box<dyn Error + Send + Sync + 'static>>`.
fn get_bundle_for_trust_domain(
&self,
trust_domain: &TrustDomain,
) -> Result<Option<&Self::Item>, Box<dyn Error + Send + Sync + 'static>>;
}
/// Represents a source of bundles queryable by [`TrustDomain`].
pub trait BundleSource {
/// The type of the bundles provided by the source.
type Item: Bundle;
/// Returns a owned bundle (set of public keys authorities) associated to the [`TrustDomain`].
/// If it cannot be found a bundle associated to the trust domain, it returns `Ok(None)`.
/// If there's is an error in source fetching the bundle, it returns an `Err<Box<dyn Error + Send + Sync + 'static>>`.
fn get_bundle_for_trust_domain(
&self,
trust_domain: &TrustDomain,
) -> Result<Option<Self::Item>, Box<dyn Error + Send + Sync + 'static>>;
}