[][src]Struct tox_packet::dht::DhtRequest

pub struct DhtRequest {
    pub rpk: PublicKey,
    pub spk: PublicKey,
    pub nonce: Nonce,
    pub payload: Vec<u8>,
}

DHT Request packet struct. DHT Request packet consists of NatPingRequest and NatPingResponse. When my known friend is not connected directly, send NatPingRequest to peers which are in Ktree. When NatPingResponse arrives to me, it means that my known friend is also searching me, and running behind NAT, so start hole-punching.

https://zetok.github.io/tox-spec/#dht-request-packets

LengthContent
10x20
32Receiver's Public Key
32Sender's Public Key
24Nonce
variablePayload

where Payload is encrypted DhtRequestPayload

Fields

rpk: PublicKey

receiver public key

spk: PublicKey

sender public key

nonce: Nonce

one time serial number

payload: Vec<u8>

payload of DhtRequest packet

Implementations

impl DhtRequest[src]

pub fn new(
    shared_secret: &PrecomputedKey,
    rpk: &PublicKey,
    spk: &PublicKey,
    dp: &DhtRequestPayload
) -> DhtRequest
[src]

create new DhtRequest object

pub fn get_payload(
    &self,
    shared_secret: &PrecomputedKey
) -> Result<DhtRequestPayload, GetPayloadError>
[src]

Decrypt payload and try to parse it as packet type.

Returns Error in case of failure:

  • fails to decrypt
  • fails to parse as given packet type

Trait Implementations

impl Clone for DhtRequest[src]

impl Debug for DhtRequest[src]

impl Eq for DhtRequest[src]

impl FromBytes for DhtRequest[src]

impl PartialEq<DhtRequest> for DhtRequest[src]

impl StructuralEq for DhtRequest[src]

impl StructuralPartialEq for DhtRequest[src]

impl ToBytes for DhtRequest[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.