Skip to main content

Config

Struct Config 

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

Configuration for a Client.

Construct with Config::new and customize with the consuming with_* methods. The endhost API URL is the only required setting: it is how the client discovers the data planes available to it, and the same single setting reaches a real SCION network or a local PocketSCION topology.

Implementations§

Source§

impl Config

Source

pub fn new(endhost_api: Url) -> Self

Creates a configuration that discovers connectivity through the given endhost API.

Source

pub fn with_auth_token(self, token: impl Into<String>) -> Self

Sets a fixed token to authenticate with the endhost API and the SNAP control plane.

Use with_auth_token_source instead when the token expires: connectivity is rebuilt on every reset, and a token captured here is reused verbatim each time.

Source

pub fn with_auth_token_source(self, source: impl TokenSource) -> Self

Sets the token source used to authenticate with the endhost API and the SNAP control plane.

The source is shared, not rebuilt: the same one is handed to every stack this configuration builds, so a refreshing source keeps its schedule and its cached token across a reset. Implement TokenSource to supply tokens that expire.

For a source scoped to the endhost API alone, reach the builder’s with_endhost_api_auth_token_source through with_stack_customizer.

Source

pub fn with_api_key(self, auth: ApiKeyAuth) -> Self

Sets an Anapaya AA API key. The client exchanges the key for the tokens that the endhost API and the SNAP control plane need.

The client exchanges the key on the first request, and renews the token in the background while the client lives. The exchange is shared, like a token source: every stack this configuration builds reuses the same token, across every reset. A refused key, or an AA out of reach, fails that first request with Error::StackBuild; is_retryable is false for a refused key and true for an AA out of reach. Construction never fails.

The AA URL has to be https, so that the key does not cross the network in cleartext. ApiKeyAuth::allow_insecure_http permits http for local testing; without it an http URL fails the first request.

The key, a token, and a token source occupy one slot: the last one set wins.

Source

pub fn with_preferred_underlay(self, underlay: PreferredUnderlay) -> Self

Sets the preferred underlay, applied to whatever endhost API discovery returns (default: UDP).

Source

pub fn with_stack_customizer( self, customizer: impl Fn(ScionStackBuilder) -> ScionStackBuilder + Send + Sync + 'static, ) -> Self

Customizes the ScionStackBuilder used to build connectivity, for settings this configuration does not expose directly (underlay-specific configuration, discovery tuning, token sources).

The hook runs every time connectivity is (re)built: on first use and after every reset. It runs after the settings above are applied, so it can override them.

Source

pub fn with_connect_timeout(self, timeout: Duration) -> Self

Sets the timeout for establishing a connection to an origin, covering name resolution and all staggered connection attempts.

Source

pub fn with_request_timeout(self, timeout: Duration) -> Self

Sets the default timeout for a whole request: connectivity build, establishment, response head, and body collection. Overridable per request with RequestBuilder::request_timeout.

It is one deadline across all of those phases, and it keeps running while the caller holds the Response — see there for what that means for body collection.

Source

pub fn with_idle_connection_timeout(self, timeout: Duration) -> Self

Sets how long an origin’s pooled connection may sit unused before an opportunistic sweep reclaims it (and its socket).

Source

pub fn with_max_origins(self, max_origins: usize) -> Self

Bounds the number of distinct origins with pooled connections. Each pooled connection holds a socket, and therefore a file descriptor; when the bound is hit, the least recently used origin is evicted (and the eviction logged).

Source

pub fn with_connection_attempt_delay(self, delay: Duration) -> Self

Sets the stagger between connection attempts to an origin’s candidate addresses: the next candidate is only tried this long after the previous one, unless it already failed (RFC 8305, Happy Eyeballs).

Source

pub fn with_quic_config(self, quic: QuicConfig) -> Self

Sets the QUIC configuration used for every connection: trust anchors (ca_certs_file / ca_certs_dir / ca_certs_pem) or a certificate verifier (with_cert_verifier / with_platform_verifier), peer verification, handshake and idle timeouts, and transport tuning. The application protocol list must contain h3 (the default).

Source

pub fn with_resolver(self, resolver: Arc<dyn ScionDnsResolver>) -> Self

Replaces the default DNS resolver (ScionTxtDnsResolver) with a caller-supplied one.

The default resolver is constructed fresh on every connectivity rebuild, because system DNS configuration is a property of the current network. An injected resolver is reused across rebuilds as-is; reacting to network changes is then its responsibility.

Source

pub fn with_dns_override( self, host: impl Into<String>, addrs: Vec<ScionIpAddr>, ) -> Self

Resolves host to addrs instead of looking it up, for a host that has no TSAR records. Applies to URLs and to CONNECT authorities alike.

Only the default resolver applies overrides. A resolver injected with with_resolver does its own resolution.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

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<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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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