spiffe/svid/
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
//! X.509-SVID and JWT-SVID types.

use std::error::Error;

pub mod jwt;
pub mod x509;

/// Represents a SPIFFE Verifiable Identity Document (SVID).
pub trait Svid {}

/// Represents a source of SPIFFE SVIDs.
pub trait SvidSource {
    /// The type of the SVIDs provided by the source.
    type Item: Svid;

    /// Returns an owned SVID.
    /// If it cannot be found an SVID in the source, it returns `Ok(None)`.
    /// If there's is an error in source fetching the SVID, it returns an `Err<Box<dyn Error + Send + Sync + 'static>>`.
    fn get_svid(&self) -> Result<Option<Self::Item>, Box<dyn Error + Send + Sync + 'static>>;
}

/// Represents a source of SPIFFE SVIDs.
pub trait SvidRefSource {
    /// The type of the SVIDs provided by the source.
    type Item: Svid;

    /// Returns an SVID reference.
    /// If it cannot be found an SVID in the source, it returns `Ok(None)`.
    /// If there's is an error in source fetching the SVID, it returns an `Err<Box<dyn Error + Send + Sync + 'static>>`.
    fn get_svid_ref(&self) -> Result<Option<&Self::Item>, Box<dyn Error + Send + Sync + 'static>>;
}