logo
pub enum KademliaHandlerIn<TUserData> {
    Reset(KademliaRequestId),
    FindNodeReq {
        key: Vec<u8, Global>,
        user_data: TUserData,
    },
    FindNodeRes {
        closer_peers: Vec<KadPeer, Global>,
        request_id: KademliaRequestId,
    },
    GetProvidersReq {
        key: Key,
        user_data: TUserData,
    },
    GetProvidersRes {
        closer_peers: Vec<KadPeer, Global>,
        provider_peers: Vec<KadPeer, Global>,
        request_id: KademliaRequestId,
    },
    AddProvider {
        key: Key,
        provider: KadPeer,
    },
    GetRecord {
        key: Key,
        user_data: TUserData,
    },
    GetRecordRes {
        record: Option<Record>,
        closer_peers: Vec<KadPeer, Global>,
        request_id: KademliaRequestId,
    },
    PutRecord {
        record: Record,
        user_data: TUserData,
    },
    PutRecordRes {
        key: Key,
        value: Vec<u8, Global>,
        request_id: KademliaRequestId,
    },
}
Expand description

Event to send to the handler.

Variants

Reset(KademliaRequestId)

Resets the (sub)stream associated with the given request ID, thus signaling an error to the remote.

Explicitly resetting the (sub)stream associated with a request can be used as an alternative to letting requests simply time out on the remote peer, thus potentially avoiding some delay for the query on the remote.

FindNodeReq

Fields

key: Vec<u8, Global>

Identifier of the node.

user_data: TUserData

Custom user data. Passed back in the out event when the results arrive.

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, Global>

Results of the request.

request_id: KademliaRequestId

Identifier of the request that was made by the remote.

It is a logic error to use an id of the handler of a different node.

Response to a FindNodeReq.

GetProvidersReq

Fields

key: Key

Identifier being searched.

user_data: TUserData

Custom user data. Passed back in the out event when the results arrive.

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

GetProvidersRes

Fields

closer_peers: Vec<KadPeer, Global>

Nodes closest to the key.

provider_peers: Vec<KadPeer, Global>

Known providers for this key.

request_id: KademliaRequestId

Identifier of the request that was made by the remote.

It is a logic error to use an id of the handler of a different node.

Response to a GetProvidersReq.

AddProvider

Fields

key: Key

Key for which we should add providers.

provider: KadPeer

Known provider for this key.

Indicates that this provider is known for this key.

The API of the handler doesn’t expose any event that allows you to know whether this succeeded.

GetRecord

Fields

key: Key

The key of the record.

user_data: TUserData

Custom data. Passed back in the out event when the results arrive.

Request to retrieve a record from the DHT.

GetRecordRes

Fields

record: Option<Record>

The value that might have been found in our storage.

closer_peers: Vec<KadPeer, Global>

Nodes that are closer to the key we were searching for.

request_id: KademliaRequestId

Identifier of the request that was made by the remote.

Response to a GetRecord request.

PutRecord

Fields

record: Record
user_data: TUserData

Custom data. Passed back in the out event when the results arrive.

Put a value into the dht records.

PutRecordRes

Fields

key: Key

Key of the value that was put.

value: Vec<u8, Global>

Value that was put.

request_id: KademliaRequestId

Identifier of the request that was made by the remote.

Response to a PutRecord.

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.