ClientConfigStreamBuilder

Trait ClientConfigStreamBuilder 

Source
pub trait ClientConfigStreamBuilder {
    type ConfigStream: Stream<Item = Result<Arc<ClientConfig>, ClientConfigStreamError>> + Send + Sync + Unpin + 'static;

    // Required method
    fn build(
        &mut self,
    ) -> impl Future<Output = Result<Self::ConfigStream, ClientConfigStreamError>> + Send;
}
Expand description

A factory for producing a stream of rustls::ClientConfig.

Implement this trait to define how your application sources TLS configs (e.g., file watchers, secret managers, pull-from-API).

The returned stream should yield complete ClientConfig values. Each item replaces the provider’s current config atomically (via ArcSwap).

§Contract

§Examples

use std::sync::Arc;
use rustls::ClientConfig;
use tokio_stream::{Stream, wrappers::ReceiverStream};

struct MyConfigProvider;

impl ClientConfigStreamBuilder for MyConfigProvider {
    type ConfigStream = ReceiverStream<Result<Arc<ClientConfig>, ClientConfigStreamError>>;

    async fn build(
        &mut self,
    ) -> Result<Self::ConfigStream, ClientConfigStreamError> {
        // Construct a stream that yields ClientConfig updates.
        // See the SPIFFE implementation in `rustls-spiffe` for a full example.
        unimplemented!()
    }
}

Required Associated Types§

Source

type ConfigStream: Stream<Item = Result<Arc<ClientConfig>, ClientConfigStreamError>> + Send + Sync + Unpin + 'static

The stream type produced by this builder.

Each item is either a fresh ClientConfig or an error explaining why the update failed.

Required Methods§

Source

fn build( &mut self, ) -> impl Future<Output = Result<Self::ConfigStream, ClientConfigStreamError>> + Send

Asynchronously construct a new configuration stream.

The provider will:

  • call this once during startup to obtain the initial stream,
  • read the first config to seed its state,
  • continue to poll the provided stream for new configs
  • upon stream failure or completion, call it again with exponential backoff until a new stream is available.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§