pub struct ClientBuilder { /* private fields */ }Expand description
Build a Client.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn new(
url: impl Into<RelayUrl>,
secret_key: SecretKey,
dns_resolver: DnsResolver,
) -> Self
pub fn new( url: impl Into<RelayUrl>, secret_key: SecretKey, dns_resolver: DnsResolver, ) -> Self
Create a new ClientBuilder
Sourcepub fn tls_client_config(self, tls_config: ClientConfig) -> Self
pub fn tls_client_config(self, tls_config: ClientConfig) -> Self
Sets a custom TLS config.
This is a required option.
You can construct a [rustls::ClientConfig] by combining a [rustls::crypto::CryptoProvider]
with a tls::CaTlsConfig using tls::CaTlsConfig::client_config, for example:
use std::sync::Arc;
use iroh_relay::tls::CaTlsConfig;
let crypto_provider: rustls::crypto::CryptoProvider = todo!();
let client_config = CaTlsConfig::default().client_config(Arc::new(crypto_provider));If you enable the tls-ring or tls-aws-lc-rs feature, you can use the enabled crypto provider
by using tls::default_provider.
Sourcepub fn address_family_selector<S>(self, selector: S) -> Self
pub fn address_family_selector<S>(self, selector: S) -> Self
Sets a callback hinting whether to prefer IPv6 when dialing the relay.
The callback runs on each dial. When it returns true, IPv6 addresses
are tried first and IPv4 dials are held back slightly, biasing the
happy-eyeballs race towards IPv6; when it returns false, IPv4 is
preferred. Only return true when IPv6 is expected to work, since
otherwise the bias just delays the connection.
Sourcepub fn proxy_url(self, url: Url) -> Self
pub fn proxy_url(self, url: Url) -> Self
Set an explicit proxy url to proxy all HTTP(S) traffic through.
Sourcepub fn auth_token(self, token: impl Into<String>) -> Self
pub fn auth_token(self, token: impl Into<String>) -> Self
Sets an authorization token.
On native targets, the token is sent as an Authorization: Bearer TOKEN
header on the WebSocket upgrade request that establishes the relay
connection. The token must be a valid HTTP header field value, if not
Self::connect will return ConnectError::InvalidAuthToken.
When compiled to WebAssembly the token is sent as a ?token=TOKEN
query parameter on the upgrade URL, since browsers don’t allow setting
headers on WebSocket requests.
Sourcepub fn key_cache_capacity(self, capacity: usize) -> Self
pub fn key_cache_capacity(self, capacity: usize) -> Self
Set the capacity of the cache for public keys.
Sourcepub async fn connect(&self) -> Result<Client, ConnectError>
Available on non-wasm_browser only.
pub async fn connect(&self) -> Result<Client, ConnectError>
wasm_browser only.Establishes a new connection to the relay server.
Trait Implementations§
Source§impl Clone for ClientBuilder
impl Clone for ClientBuilder
Source§fn clone(&self) -> ClientBuilder
fn clone(&self) -> ClientBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ClientBuilder
impl !RefUnwindSafe for ClientBuilder
impl Send for ClientBuilder
impl Sync for ClientBuilder
impl Unpin for ClientBuilder
impl !UnwindSafe for ClientBuilder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more