Enum libp2p_kad::handler::KademliaHandlerEvent

source ·
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

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.

Fields

§

FindNodeReq

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.

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.

§

FindNodeRes

Response to an KademliaHandlerIn::FindNodeReq.

Fields

§closer_peers: Vec<KadPeer>

Results of the request.

§user_data: TUserData

The user data passed to the FindNodeReq.

§

GetProvidersReq

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

Fields

§key: Key

The key for which providers are requested.

§request_id: KademliaRequestId

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

§

GetProvidersRes

Response to an KademliaHandlerIn::GetProvidersReq.

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.

§

QueryError

An error happened when performing a query.

Fields

§error: KademliaHandlerQueryErr

The error that happened.

§user_data: TUserData

The user data passed to the query.

§

AddProvider

The peer announced itself as a provider of a key.

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.

§

GetRecord

Request to get a value from the dht records

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.

§

GetRecordRes

Response to a KademliaHandlerIn::GetRecord.

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.

§

PutRecord

Request to put a value in the dht records

Fields

§record: Record
§request_id: KademliaRequestId

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

§

PutRecordRes

Response to a request to store a record.

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.

Trait Implementations§

source§

impl<TUserData: Debug> Debug for KademliaHandlerEvent<TUserData>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<TUserData> !Freeze for KademliaHandlerEvent<TUserData>

§

impl<TUserData> !RefUnwindSafe for KademliaHandlerEvent<TUserData>

§

impl<TUserData> Send for KademliaHandlerEvent<TUserData>
where TUserData: Send,

§

impl<TUserData> Sync for KademliaHandlerEvent<TUserData>
where TUserData: Sync,

§

impl<TUserData> Unpin for KademliaHandlerEvent<TUserData>
where TUserData: Unpin,

§

impl<TUserData> !UnwindSafe for KademliaHandlerEvent<TUserData>

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more