[−][src]Struct tox_packet::dht::PingRequest
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
Length | Content |
---|---|
1 | 0x00 |
32 | Public Key |
24 | Nonce |
25 | Payload |
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]
shared_secret: &PrecomputedKey,
pk: &PublicKey,
payload: &PingRequestPayload
) -> PingRequest
create new PingRequest object
pub fn get_payload(
&self,
shared_secret: &PrecomputedKey
) -> Result<PingRequestPayload, GetPayloadError>
[src]
&self,
shared_secret: &PrecomputedKey
) -> Result<PingRequestPayload, GetPayloadError>
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]
pub fn clone(&self) -> PingRequest
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for PingRequest
[src]
impl Eq for PingRequest
[src]
impl FromBytes for PingRequest
[src]
impl PartialEq<PingRequest> for PingRequest
[src]
pub fn eq(&self, other: &PingRequest) -> bool
[src]
pub fn ne(&self, other: &PingRequest) -> bool
[src]
impl StructuralEq for PingRequest
[src]
impl StructuralPartialEq for PingRequest
[src]
impl ToBytes for PingRequest
[src]
Auto Trait Implementations
impl RefUnwindSafe for PingRequest
[src]
impl Send for PingRequest
[src]
impl Sync for PingRequest
[src]
impl Unpin for PingRequest
[src]
impl UnwindSafe for PingRequest
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,