pub enum KademliaHandlerEvent<TUserData> {
    ProtocolConfirmed {
        endpoint: ConnectedPoint,
    },
    FindNodeReq {
        key: Vec<u8>,
        request_id: KademliaRequestId,
    },
    FindNodeRes {
        closer_peers: Vec<KadPeer>,
        user_data: TUserData,
    },
    GetProvidersReq {
        key: Key,
        request_id: KademliaRequestId,
    },
    GetProvidersRes {
        closer_peers: Vec<KadPeer>,
        provider_peers: Vec<KadPeer>,
        user_data: TUserData,
    },
    QueryError {
        error: KademliaHandlerQueryErr,
        user_data: TUserData,
    },
    AddProvider {
        key: Key,
        provider: KadPeer,
    },
    GetRecord {
        key: Key,
        request_id: KademliaRequestId,
    },
    GetRecordRes {
        record: Option<Record>,
        closer_peers: Vec<KadPeer>,
        user_data: TUserData,
    },
    PutRecord {
        record: Record,
        request_id: KademliaRequestId,
    },
    PutRecordRes {
        key: Key,
        value: Vec<u8>,
        user_data: TUserData,
    },
}
Expand description

Event produced by the Kademlia handler.

Variants§

§

ProtocolConfirmed

Fields

§endpoint: ConnectedPoint

The configured protocol name has been confirmed by the peer through a successfully negotiated substream.

This event is only emitted once by a handler upon the first successfully negotiated inbound or outbound substream and indicates that the connected peer participates in the Kademlia overlay network identified by the configured protocol name.

§

FindNodeReq

Fields

§key: Vec<u8>

The key for which to locate the closest nodes.

§request_id: KademliaRequestId

Identifier of the request. Needs to be passed back when answering.

Request for the list of nodes whose IDs are the closest to key. The number of nodes returned is not specified, but should be around 20.

§

FindNodeRes

Fields

§closer_peers: Vec<KadPeer>

Results of the request.

§user_data: TUserData

The user data passed to the FindNodeReq.

Response to an KademliaHandlerIn::FindNodeReq.

§

GetProvidersReq

Fields

§key: Key

The key for which providers are requested.

§request_id: KademliaRequestId

Identifier of the request. Needs to be passed back when answering.

Same as FindNodeReq, but should also return the entries of the local providers list for this key.

§

GetProvidersRes

Fields

§closer_peers: Vec<KadPeer>

Nodes closest to the key.

§provider_peers: Vec<KadPeer>

Known providers for this key.

§user_data: TUserData

The user data passed to the GetProvidersReq.

Response to an KademliaHandlerIn::GetProvidersReq.

§

QueryError

Fields

§error: KademliaHandlerQueryErr

The error that happened.

§user_data: TUserData

The user data passed to the query.

An error happened when performing a query.

§

AddProvider

Fields

§key: Key

The key for which the peer is a provider of the associated value.

§provider: KadPeer

The peer that is the provider of the value for key.

The peer announced itself as a provider of a key.

§

GetRecord

Fields

§key: Key

Key for which we should look in the dht

§request_id: KademliaRequestId

Identifier of the request. Needs to be passed back when answering.

Request to get a value from the dht records

§

GetRecordRes

Fields

§record: Option<Record>

The result is present if the key has been found

§closer_peers: Vec<KadPeer>

Nodes closest to the key.

§user_data: TUserData

The user data passed to the GetValue.

Response to a KademliaHandlerIn::GetRecord.

§

PutRecord

Fields

§record: Record
§request_id: KademliaRequestId

Identifier of the request. Needs to be passed back when answering.

Request to put a value in the dht records

§

PutRecordRes

Fields

§key: Key

The key of the stored record.

§value: Vec<u8>

The value of the stored record.

§user_data: TUserData

The user data passed to the PutValue.

Response to a request to store a record.

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.