pub struct X509SourceBuilder { /* private fields */ }
Expand description
Builder for X509Source
.
Implementations§
Source§impl X509SourceBuilder
A builder for creating a new X509Source
with optional client and svid_picker configurations.
impl X509SourceBuilder
A builder for creating a new X509Source
with optional client and svid_picker configurations.
Allows for customization by accepting a client and/or svid_picker.
§Example
use spiffe::workload_api::x509_source::{SvidPicker, X509SourceBuilder};
use spiffe::{WorkloadApiClient, X509Svid};
use std::error::Error;
#[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
}
}
let client = WorkloadApiClient::default().await?;
let source = X509SourceBuilder::new()
.with_client(client)
.with_picker(Box::new(SecondSvidPicker))
.build()
.await?;
§Returns
A Result
containing an Arc<X509Source>
or an X509SourceError
if an error occurs.
Sourcepub fn with_client(self, client: WorkloadApiClient) -> Self
pub fn with_client(self, client: WorkloadApiClient) -> Self
Sets the Workload API client to be used by the X509Source.
Sourcepub fn with_picker(self, svid_picker: Box<dyn SvidPicker>) -> Self
pub fn with_picker(self, svid_picker: Box<dyn SvidPicker>) -> Self
Sets the svid_picker to be used by the X509Source.
Sourcepub async fn build(self) -> Result<Arc<X509Source>, X509SourceError>
pub async fn build(self) -> Result<Arc<X509Source>, X509SourceError>
Builds an X509Source
using the provided configuration.
Trait Implementations§
Source§impl Debug for X509SourceBuilder
impl Debug for X509SourceBuilder
Auto Trait Implementations§
impl !Freeze for X509SourceBuilder
impl !RefUnwindSafe for X509SourceBuilder
impl Send for X509SourceBuilder
impl Sync for X509SourceBuilder
impl Unpin for X509SourceBuilder
impl !UnwindSafe for X509SourceBuilder
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request