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
user_data: TUserDataCustom user data. Passed back in the out event when the results arrive.
FindNodeRes
Response to a FindNodeReq.
Fields
request_id: KademliaRequestIdIdentifier 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
user_data: TUserDataCustom user data. Passed back in the out event when the results arrive.
GetProvidersRes
Response to a GetProvidersReq.
Fields
request_id: KademliaRequestIdIdentifier 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
GetRecord
Request to retrieve a record from the DHT.
Fields
user_data: TUserDataCustom data. Passed back in the out event when the results arrive.
GetRecordRes
Response to a GetRecord request.
Fields
request_id: KademliaRequestIdIdentifier of the request that was made by the remote.
PutRecord
Put a value into the dht records.
Fields
user_data: TUserDataCustom data. Passed back in the out event when the results arrive.
PutRecordRes
Response to a PutRecord.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more