spiffe::workload_api::x509_source

Trait SvidPicker

Source
pub trait SvidPicker:
    Debug
    + Send
    + Sync {
    // Required method
    fn pick_svid<'a>(&self, svids: &'a [X509Svid]) -> Option<&'a X509Svid>;
}
Expand description

SvidPicker is a trait defining the behavior for selecting an X509Svid.

Implementors of this trait must provide a concrete implementation of the pick_svid method, which takes a reference to a slice of X509Svid and returns an Option<&X509Svid>.

The trait requires that implementing types are both Send and Sync, ensuring that they can be sent between threads and accessed concurrently.

§Example

use spiffe::workload_api::x509_source::SvidPicker;
use spiffe::X509Svid;

#[derive(Debug)]
struct SecondSvidPicker;

impl SvidPicker for SecondSvidPicker {
    fn pick_svid<'a>(&self, svids: &'a [X509Svid]) -> Option<&'a X509Svid> {
        svids.get(1) // return second svid
    }
}

Required Methods§

Source

fn pick_svid<'a>(&self, svids: &'a [X509Svid]) -> Option<&'a X509Svid>

Selects an X509Svid from the provided slice of X509Svid.

§Parameters
  • svids: A reference to a slice of X509Svid from which the X509Svid should be selected.
§Returns
  • An Option<&X509Svid>, where a None value indicates that no suitable X509Svid was found.

Implementors§