pub struct ClientBuilder(/* private fields */);Expand description
A builder for constructing a Client with custom configuration.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn no_default_network(&mut self) -> &mut Self
pub fn no_default_network(&mut self) -> &mut Self
Similar to crates no-default-features, this method will remove the default Self::bootstrap, and Self::relays
effectively disabling the use of both mainline and Relays.
Or you can use Self::relays to use custom Relays.
Similarly you can use Self::bootstrap or Self::dht to use mainline with custom configurations.
Sourcepub fn dht<F>(&mut self, f: F) -> &mut Self
pub fn dht<F>(&mut self, f: F) -> &mut Self
Create a mainline::DhtBuilder if None, and allows mutating it with a callback function.
Sourcepub fn bootstrap<T: ToString>(&mut self, bootstrap: &[T]) -> &mut Self
pub fn bootstrap<T: ToString>(&mut self, bootstrap: &[T]) -> &mut Self
Convenient method to set the bootstrap nodes in Self::dht.
You can start a separate Dht network by setting this to an empty array.
If you want to extend bootstrap nodes with more nodes, you can use Self::extra_bootstrap.
Sourcepub fn extra_bootstrap<T: ToString>(&mut self, bootstrap: &[T]) -> &mut Self
pub fn extra_bootstrap<T: ToString>(&mut self, bootstrap: &[T]) -> &mut Self
Extend the DHT bootstrapping nodes.
If you want to set (override) the DHT bootstrapping nodes, use Self::bootstrap directly.
Sourcepub fn relays<T: IntoUrl + Clone>(
&mut self,
relays: &[T],
) -> Result<&mut Self, InvalidRelayUrl>
pub fn relays<T: IntoUrl + Clone>( &mut self, relays: &[T], ) -> Result<&mut Self, InvalidRelayUrl>
Set custom set of Relays.
If you want to disable relays use Self::no_relays instead.
Sourcepub fn extra_relays<T: IntoUrl + Clone>(
&mut self,
relays: &[T],
) -> Result<&mut Self, InvalidRelayUrl>
pub fn extra_relays<T: IntoUrl + Clone>( &mut self, relays: &[T], ) -> Result<&mut Self, InvalidRelayUrl>
Extend the current Self::relays with extra relays.
If you want to set (override) relays instead, use Self::relays
Sourcepub fn cache_size(&mut self, cache_size: usize) -> &mut Self
pub fn cache_size(&mut self, cache_size: usize) -> &mut Self
Set the size of the capacity of the Self::cache implementation.
If set to 0 cache will be disabled.
Sourcepub fn minimum_ttl(&mut self, ttl: u32) -> &mut Self
pub fn minimum_ttl(&mut self, ttl: u32) -> &mut Self
Set the minimum TTL value.
Limits how soon a crate::SignedPacket is considered expired.
Sourcepub fn maximum_ttl(&mut self, ttl: u32) -> &mut Self
pub fn maximum_ttl(&mut self, ttl: u32) -> &mut Self
Set the maximum TTL value.
Limits how long it takes before a crate::SignedPacket is considered expired.
Sourcepub fn cache(&mut self, cache: Arc<dyn Cache>) -> &mut Self
pub fn cache(&mut self, cache: Arc<dyn Cache>) -> &mut Self
Set a custom implementation of Cache.
Sourcepub fn request_timeout(&mut self, timeout: Duration) -> &mut Self
pub fn request_timeout(&mut self, timeout: Duration) -> &mut Self
Set the maximum request timeout for relays client.
Useful for testing NOT FOUND responses, where you want to reach the timeout sooner than the default of DEFAULT_REQUEST_TIMEOUT.
Sourcepub fn max_recursion_depth(&mut self, max_recursion_depth: u8) -> &mut Self
pub fn max_recursion_depth(&mut self, max_recursion_depth: u8) -> &mut Self
Sourcepub fn build(&self) -> Result<Client, BuildError>
pub fn build(&self) -> Result<Client, BuildError>
Try building a Client with the configuration in this builder.
Sourcepub async fn build_async(&self) -> Result<Client, BuildError>
pub async fn build_async(&self) -> Result<Client, BuildError>
Try building a Client with the configuration in this builder.
Unlike Self::build, this doesn NOT block on dns resolution when using mainline Dht.
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 more