Enum libp2p_kad::handler::KademliaHandlerIn

source ·
pub enum KademliaHandlerIn<TUserData> {
    Reset(KademliaRequestId),
    FindNodeReq {
        key: Vec<u8>,
        user_data: TUserData,
    },
    FindNodeRes {
        closer_peers: Vec<KadPeer>,
        request_id: KademliaRequestId,
    },
    GetProvidersReq {
        key: Key,
        user_data: TUserData,
    },
    GetProvidersRes {
        closer_peers: Vec<KadPeer>,
        provider_peers: Vec<KadPeer>,
        request_id: KademliaRequestId,
    },
    AddProvider {
        key: Key,
        provider: KadPeer,
    },
    GetRecord {
        key: Key,
        user_data: TUserData,
    },
    GetRecordRes {
        record: Option<Record>,
        closer_peers: Vec<KadPeer>,
        request_id: KademliaRequestId,
    },
    PutRecord {
        record: Record,
        user_data: TUserData,
    },
    PutRecordRes {
        key: Key,
        value: Vec<u8>,
        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

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>

Identifier of the node.

§user_data: TUserData

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

§

FindNodeRes

Response to a FindNodeReq.

Fields

§closer_peers: Vec<KadPeer>

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.

§

GetProvidersReq

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

Fields

§key: Key

Identifier being searched.

§user_data: TUserData

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

§

GetProvidersRes

Response to a GetProvidersReq.

Fields

§closer_peers: Vec<KadPeer>

Nodes closest to the key.

§provider_peers: Vec<KadPeer>

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.

§

AddProvider

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.

Fields

§key: Key

Key for which we should add providers.

§provider: KadPeer

Known provider for this key.

§

GetRecord

Request to retrieve a record from the DHT.

Fields

§key: Key

The key of the record.

§user_data: TUserData

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

§

GetRecordRes

Response to a GetRecord request.

Fields

§record: Option<Record>

The value that might have been found in our storage.

§closer_peers: Vec<KadPeer>

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

§request_id: KademliaRequestId

Identifier of the request that was made by the remote.

§

PutRecord

Put a value into the dht records.

Fields

§record: Record
§user_data: TUserData

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

§

PutRecordRes

Response to a PutRecord.

Fields

§key: Key

Key of the value that was put.

§value: Vec<u8>

Value that was put.

§request_id: KademliaRequestId

Identifier of the request that was made by the remote.

Trait Implementations§

source§

impl<TUserData: Debug> Debug for KademliaHandlerIn<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 KademliaHandlerIn<TUserData>

§

impl<TUserData> RefUnwindSafe for KademliaHandlerIn<TUserData>
where TUserData: RefUnwindSafe,

§

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

§

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

§

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

§

impl<TUserData> UnwindSafe for KademliaHandlerIn<TUserData>
where TUserData: UnwindSafe,

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