pub struct ScionStackBuilder { /* private fields */ }Expand description
Builder for creating a ScionStack.
§Example
use scion_stack::scionstack::builder::ScionStackBuilder;
use url::Url;
async fn setup_scion_stack() {
let control_plane_url: Url = "http://127.0.0.1:1234".parse().unwrap();
let scion_stack = ScionStackBuilder::new()
.with_endhost_api(control_plane_url)
.with_auth_token("snap_token".to_string())
.build()
.await
.unwrap();
}Implementations§
Source§impl ScionStackBuilder
impl ScionStackBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new ScionStackBuilder.
The stack uses the the endhost API to discover the available data planes. By default, udp dataplanes are preferred over snap dataplanes.
Sourcepub fn with_prefer_snap(self) -> Self
pub fn with_prefer_snap(self) -> Self
When discovering data planes, prefer SNAP data planes if available.
Sourcepub fn with_prefer_udp(self) -> Self
pub fn with_prefer_udp(self) -> Self
When discovering data planes, prefer UDP data planes if available.
Sourcepub fn with_endhost_api(self, endhost_api_url: Url) -> Self
pub fn with_endhost_api(self, endhost_api_url: Url) -> Self
Set a static endhost API
Replaces existing endhost API source.
See Self::with_endhost_api_discovery_source for more flexible configuration
Sourcepub fn with_endhost_api_discovery_source(
self,
source: impl EndhostApiSource,
) -> Self
pub fn with_endhost_api_discovery_source( self, source: impl EndhostApiSource, ) -> Self
Sets how the client will find its endhost APIs.
If none is set, the stack will fall back to using the global discovery API.
Sourcepub fn with_endhost_api_auth_token_source(
self,
source: impl TokenSource,
) -> Self
pub fn with_endhost_api_auth_token_source( self, source: impl TokenSource, ) -> Self
Set a token source to use for authentication with the endhost API.
Sourcepub fn with_endhost_api_auth_token(self, token: String) -> Self
pub fn with_endhost_api_auth_token(self, token: String) -> Self
Set a static token to use for authentication with the endhost API.
Sourcepub fn with_auth_token_source(self, source: impl TokenSource) -> Self
pub fn with_auth_token_source(self, source: impl TokenSource) -> Self
Set a token source to use for authentication both with the endhost API and the SNAP control plane. If a more specific token source is set, it takes precedence over this token source.
Sourcepub fn with_auth_token(self, token: String) -> Self
pub fn with_auth_token(self, token: String) -> Self
Set a static token to use for authentication both with the endhost API and the SNAP control plane. If a more specific token is set, it takes precedence over this token.
Sourcepub fn with_endhost_api_discovery_max_groups(self, max_groups: usize) -> Self
pub fn with_endhost_api_discovery_max_groups(self, max_groups: usize) -> Self
Set the maximum number of API groups to probe during endhost API discovery.
Groups are ordered by priority; only the first max_groups non-empty
groups returned by the discovery source are considered. Defaults to 5.
Sourcepub fn with_endhost_api_discovery_apis_per_group(
self,
apis_per_group: usize,
) -> Self
pub fn with_endhost_api_discovery_apis_per_group( self, apis_per_group: usize, ) -> Self
Set the maximum number of APIs to probe per group during endhost API discovery.
APIs are selected at random within each group. Setting this to a higher value increases redundancy at the cost of additional concurrent connections. Defaults to 2.
Sourcepub fn with_endhost_api_discovery_per_group_delay(
self,
per_group_delay: Duration,
) -> Self
pub fn with_endhost_api_discovery_per_group_delay( self, per_group_delay: Duration, ) -> Self
Set the delay before APIs in group k begin connecting, measured from
the start of discovery.
Group k starts after k × per_group_delay or as soon as group
k-1 is fully exhausted, whichever comes first. A shorter delay reduces
time-to-connect when a high-priority group is slow, at the cost of
additional concurrent connections to lower-priority groups. Defaults to
500 ms.
Sourcepub fn with_snap_underlay_config(self, config: SnapUnderlayConfig) -> Self
pub fn with_snap_underlay_config(self, config: SnapUnderlayConfig) -> Self
Set SNAP underlay specific configuration for the SCION stack.
Sourcepub fn with_udp_underlay_config(self, config: UdpUnderlayConfig) -> Self
pub fn with_udp_underlay_config(self, config: UdpUnderlayConfig) -> Self
Set UDP underlay specific configuration for the SCION stack.
Sourcepub async fn build(self) -> Result<ScionStack, BuildScionStackError>
pub async fn build(self) -> Result<ScionStack, BuildScionStackError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ScionStackBuilder
impl !RefUnwindSafe for ScionStackBuilder
impl Send for ScionStackBuilder
impl Sync for ScionStackBuilder
impl Unpin for ScionStackBuilder
impl UnsafeUnpin for ScionStackBuilder
impl !UnwindSafe for ScionStackBuilder
Blanket Implementations§
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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§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>
T in a tonic::Request