[][src]Struct tox_packet::dht::PingRequest

pub struct PingRequest {
    pub pk: PublicKey,
    pub nonce: Nonce,
    pub payload: Vec<u8>,
}

Ping request packet struct. Every 60 seconds DHT node sends PingRequest packet to peers to check whether it is alive. When PingRequest is received DHT node should respond with PingResponse that contains the same ping id inside it's encrypted payload as it got from PingRequest. If PingResponse doesn't arrive for 122 seconds the DHT node removes peer from ktree and marks it as offline if the peer is known friend.

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

LengthContent
10x00
32Public Key
24Nonce
25Payload

where Payload is encrypted PingRequestPayload

Fields

pk: PublicKey

public key used for payload encryption

nonce: Nonce

one time serial number

payload: Vec<u8>

encrypted payload

Implementations

impl PingRequest[src]

pub fn new(
    shared_secret: &PrecomputedKey,
    pk: &PublicKey,
    payload: &PingRequestPayload
) -> PingRequest
[src]

create new PingRequest object

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

Decrypt payload and try to parse it as PingRequestPayload.

Returns Error in case of failure:

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

Trait Implementations

impl Clone for PingRequest[src]

impl Debug for PingRequest[src]

impl Eq for PingRequest[src]

impl FromBytes for PingRequest[src]

impl PartialEq<PingRequest> for PingRequest[src]

impl StructuralEq for PingRequest[src]

impl StructuralPartialEq for PingRequest[src]

impl ToBytes for PingRequest[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.