pub trait DhtHandler<N: DhtNode>: Sync {
Show 14 methods
// Required methods
fn dht(&self) -> Arc<Dht<N>>;
fn node<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = N> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn ping<'life0, 'async_trait>(
&'life0 self,
channel: ChannelPtr,
) -> Pin<Box<dyn Future<Output = Result<N>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn on_new_node<'life0, 'life1, 'async_trait>(
&'life0 self,
node: &'life1 N,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn fetch_nodes<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
node: &'life1 N,
key: &'life2 Hash,
) -> Pin<Box<dyn Future<Output = Result<Vec<N>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided methods
fn announce<'life0, 'life1, 'life2, 'async_trait, M>(
&'life0 self,
key: &'life1 Hash,
message: &'life2 M,
router: DhtRouterPtr<N>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where N: 'async_trait,
M: 'async_trait + Message,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn bootstrap<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn add_node<'life0, 'async_trait>(
&'life0 self,
node: N,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where N: 'async_trait,
Self: 'async_trait,
'life0: 'async_trait { ... }
fn update_node<'life0, 'life1, 'async_trait>(
&'life0 self,
node: &'life1 N,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn fetch_nodes_sp<'life0, 'life1, 'async_trait>(
&'life0 self,
semaphore: Arc<Semaphore>,
node: N,
key: &'life1 Hash,
) -> Pin<Box<dyn Future<Output = (N, Result<Vec<N>>)> + Send + 'async_trait>>
where N: 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn lookup_nodes<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 Hash,
) -> Pin<Box<dyn Future<Output = Result<Vec<N>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn get_channel<'life0, 'life1, 'async_trait>(
&'life0 self,
node: &'life1 N,
topic: Option<Hash>,
) -> Pin<Box<dyn Future<Output = Result<ChannelPtr>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn cleanup_channel<'life0, 'async_trait>(
&'life0 self,
channel: ChannelPtr,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn add_to_router<'life0, 'life1, 'async_trait>(
&'life0 self,
router: DhtRouterPtr<N>,
key: &'life1 Hash,
router_items: Vec<DhtRouterItem<N>>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where N: 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}
Required Methods§
fn dht(&self) -> Arc<Dht<N>>
Sourcefn node<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = N> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn node<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = N> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get our own node
Sourcefn ping<'life0, 'async_trait>(
&'life0 self,
channel: ChannelPtr,
) -> Pin<Box<dyn Future<Output = Result<N>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn ping<'life0, 'async_trait>(
&'life0 self,
channel: ChannelPtr,
) -> Pin<Box<dyn Future<Output = Result<N>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send a DHT ping request
Sourcefn on_new_node<'life0, 'life1, 'async_trait>(
&'life0 self,
node: &'life1 N,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_new_node<'life0, 'life1, 'async_trait>(
&'life0 self,
node: &'life1 N,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Triggered when we find a new node
Sourcefn fetch_nodes<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
node: &'life1 N,
key: &'life2 Hash,
) -> Pin<Box<dyn Future<Output = Result<Vec<N>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn fetch_nodes<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
node: &'life1 N,
key: &'life2 Hash,
) -> Pin<Box<dyn Future<Output = Result<Vec<N>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Send FIND NODES request to a peer to get nodes close to key
Provided Methods§
Sourcefn announce<'life0, 'life1, 'life2, 'async_trait, M>(
&'life0 self,
key: &'life1 Hash,
message: &'life2 M,
router: DhtRouterPtr<N>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
N: 'async_trait,
M: 'async_trait + Message,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn announce<'life0, 'life1, 'life2, 'async_trait, M>(
&'life0 self,
key: &'life1 Hash,
message: &'life2 M,
router: DhtRouterPtr<N>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
N: 'async_trait,
M: 'async_trait + Message,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Announce message for a key, and add ourselves to router
Sourcefn bootstrap<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn bootstrap<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Lookup our own node id to bootstrap our DHT
Sourcefn add_node<'life0, 'async_trait>(
&'life0 self,
node: N,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
N: 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
fn add_node<'life0, 'async_trait>(
&'life0 self,
node: N,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
N: 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
Add a node in the correct bucket
Sourcefn update_node<'life0, 'life1, 'async_trait>(
&'life0 self,
node: &'life1 N,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update_node<'life0, 'life1, 'async_trait>(
&'life0 self,
node: &'life1 N,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Move a node to the tail in its bucket,
to show that it is the most recently seen in the bucket.
If the node is not in a bucket it will be added using add_node
Sourcefn fetch_nodes_sp<'life0, 'life1, 'async_trait>(
&'life0 self,
semaphore: Arc<Semaphore>,
node: N,
key: &'life1 Hash,
) -> Pin<Box<dyn Future<Output = (N, Result<Vec<N>>)> + Send + 'async_trait>>where
N: 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn fetch_nodes_sp<'life0, 'life1, 'async_trait>(
&'life0 self,
semaphore: Arc<Semaphore>,
node: N,
key: &'life1 Hash,
) -> Pin<Box<dyn Future<Output = (N, Result<Vec<N>>)> + Send + 'async_trait>>where
N: 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Wait to acquire a semaphore, then run self.fetch_nodes
.
This is meant to be used in lookup_nodes
.
Sourcefn lookup_nodes<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 Hash,
) -> Pin<Box<dyn Future<Output = Result<Vec<N>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn lookup_nodes<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 Hash,
) -> Pin<Box<dyn Future<Output = Result<Vec<N>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Find k
nodes closest to a key
Sourcefn get_channel<'life0, 'life1, 'async_trait>(
&'life0 self,
node: &'life1 N,
topic: Option<Hash>,
) -> Pin<Box<dyn Future<Output = Result<ChannelPtr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_channel<'life0, 'life1, 'async_trait>(
&'life0 self,
node: &'life1 N,
topic: Option<Hash>,
) -> Pin<Box<dyn Future<Output = Result<ChannelPtr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a channel (existing or create a new one) to node
about topic
.
Don’t forget to call cleanup_channel()
once you are done with it.
Sourcefn cleanup_channel<'life0, 'async_trait>(
&'life0 self,
channel: ChannelPtr,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn cleanup_channel<'life0, 'async_trait>(
&'life0 self,
channel: ChannelPtr,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Decrement the channel usage count, if it becomes 0 then set the topic to None, so that this channel is available for another task
Sourcefn add_to_router<'life0, 'life1, 'async_trait>(
&'life0 self,
router: DhtRouterPtr<N>,
key: &'life1 Hash,
router_items: Vec<DhtRouterItem<N>>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
N: 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_to_router<'life0, 'life1, 'async_trait>(
&'life0 self,
router: DhtRouterPtr<N>,
key: &'life1 Hash,
router_items: Vec<DhtRouterItem<N>>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
N: 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Add nodes as a provider for a key
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.