WorkloadApiClient

Struct WorkloadApiClient 

Source
pub struct WorkloadApiClient { /* private fields */ }
Expand description

Client for the SPIFFE Workload API.

Provides one-shot calls and streaming updates for X.509 and JWT SVIDs and bundles. For an always-up-to-date, shareable source of X.509 material with automatic reconnection, see crate::X509Source.

Implementations§

Source§

impl WorkloadApiClient

Source

pub fn socket_path(&self) -> &str

Returns the configured Workload API socket path.

Source

pub async fn new_from_path( path: impl AsRef<str>, ) -> Result<Self, GrpcClientError>

Connects to the Workload API using the given UNIX domain socket path.

The path may optionally be prefixed with unix: (e.g. unix:/tmp/spire-agent/public/api.sock).

Source

pub async fn reconnect(&mut self) -> Result<(), GrpcClientError>

Rebuilds the underlying gRPC channel.

This is intended for manual recovery scenarios. Higher-level abstractions such as X509Source typically create fresh clients and manage reconnection automatically.

Source

pub async fn default() -> Result<Self, GrpcClientError>

Connects to the Workload API using SPIFFE_ENDPOINT_SOCKET.

Source

pub fn new( socket_path: impl AsRef<str>, conn: Channel, ) -> Result<Self, GrpcClientError>

Creates a client from an existing gRPC channel.

This is primarily useful for tests or advanced transport customization.

Source

pub async fn fetch_x509_svid(&mut self) -> Result<X509Svid, GrpcClientError>

Fetches the default X.509 SVID for the calling workload.

Source

pub async fn fetch_all_x509_svids( &mut self, ) -> Result<Vec<X509Svid>, GrpcClientError>

Fetches all X.509 SVIDs available to the calling workload.

Source

pub async fn fetch_x509_bundles( &mut self, ) -> Result<X509BundleSet, GrpcClientError>

Fetches the current X.509 bundle set.

Source

pub async fn fetch_jwt_bundles( &mut self, ) -> Result<JwtBundleSet, GrpcClientError>

Fetches the current JWT bundle set.

Source

pub async fn fetch_x509_context( &mut self, ) -> Result<X509Context, GrpcClientError>

Fetches the current X.509 context (SVIDs and bundles).

Source

pub async fn fetch_jwt_svid<T: AsRef<str> + ToString>( &mut self, audience: &[T], spiffe_id: Option<&SpiffeId>, ) -> Result<JwtSvid, GrpcClientError>

Fetches a JWT-SVID for the given audience and optional SPIFFE ID.

If spiffe_id is None, the Workload API returns the default identity.

Source

pub async fn fetch_jwt_token<T: AsRef<str> + ToString>( &mut self, audience: &[T], spiffe_id: Option<&SpiffeId>, ) -> Result<String, GrpcClientError>

Fetches a JWT-SVID token string for the given audience and optional SPIFFE ID.

If spiffe_id is None, the Workload API returns the default identity.

Source

pub async fn validate_jwt_token<T: AsRef<str> + ToString>( &mut self, audience: T, jwt_token: &str, ) -> Result<JwtSvid, GrpcClientError>

Validates a JWT-SVID token for the given audience and returns the parsed JwtSvid.

Source

pub async fn stream_x509_contexts( &mut self, ) -> Result<impl Stream<Item = Result<X509Context, GrpcClientError>> + use<>, GrpcClientError>

Streams X.509 context updates from the Workload API.

Source

pub async fn stream_x509_svids( &mut self, ) -> Result<impl Stream<Item = Result<X509Svid, GrpcClientError>> + use<>, GrpcClientError>

Streams X.509 SVID updates from the Workload API.

Source

pub async fn stream_x509_bundles( &mut self, ) -> Result<impl Stream<Item = Result<X509BundleSet, GrpcClientError>> + use<>, GrpcClientError>

Streams X.509 bundle set updates from the Workload API.

Source

pub async fn stream_jwt_bundles( &mut self, ) -> Result<impl Stream<Item = Result<JwtBundleSet, GrpcClientError>> + use<>, GrpcClientError>

Streams JWT bundle set updates from the Workload API.

Trait Implementations§

Source§

impl Clone for WorkloadApiClient

Source§

fn clone(&self) -> WorkloadApiClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WorkloadApiClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more