Struct DHTBuilder

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

Helps to configure and create new DHT instances.

Implementations§

Source§

impl DHTBuilder

Source

pub fn new() -> DHTBuilder

Creates a new DHTBuilder

Source

pub fn initial_id(self, id: Id) -> Self

Set the initial Id for your DHT node.

If you don’t specify one, DHT will try to generate one based on its external IPv4 address (if known). If it doesn’t know its external IPv4 address, DHT will generate a random Id and change it later if it learns that it’s not valid for its IPv4 address.

Source

pub fn listen_addr(self, listen_addr: SocketAddrV4) -> Self

Sets the IPv4 address and port that the DHT should bind its UDP socket to.

If not specified, it will default to 0.0.0.0:6881

Source

pub fn ip_source(self, ip_source: Box<dyn IPV4AddrSource + Send>) -> Self

Provides an IPV4AddrSource implementation to the DHT.

DHT will use this object to learn its external IPv4 address and keep up to date when the IP changes. If unspecified, the default implementation is IPV4Consensus.

Source

pub fn route_table(self, route_table: Box<dyn NodeStorage + Send>) -> Self

Provides a NodeStorage implementation to the DHT.

DHT will use this to store its routing tables. If unspecified, the default implementation is NodeBucketStorage which works roughly the BEP0005 describes.

Source

pub fn settings(self, settings: DHTSettings) -> Self

Provides a DHTSettings object to the DHT.

DHTSettings can be built with DHTSettingsBuilder but the defaults should work fine in most cases.

Source

pub fn build(self, shutdown_rx: ShutdownReceiver) -> Result<DHT, RustyDHTError>

Build a DHT

This must be called from within a tokio Runtime context because it constructs a tokio UdpSocket. See tokio::net::UdpSocket.

Trait Implementations§

Source§

impl Clone for DHTBuilder

Source§

fn clone(&self) -> DHTBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Default for DHTBuilder

Source§

fn default() -> DHTBuilder

Returns the “default value” for a type. 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<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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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