pub struct PingResponse {
pub pk: PublicKey,
pub nonce: Nonce,
pub payload: Vec<u8>,
}
Expand description
Ping response packet struct. 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
.
https://zetok.github.io/tox-spec/#dht-packet
Length | Content |
---|---|
1 | 0x01 |
32 | Public Key |
24 | Nonce |
25 | Payload |
where Payload is encrypted PingResponsePayload
Fields§
§pk: PublicKey
public key used for payload encryption
nonce: Nonce
one time serial number
payload: Vec<u8>
encrypted payload
Implementations§
Source§impl PingResponse
impl PingResponse
Sourcepub fn new(
shared_secret: &PrecomputedKey,
pk: &PublicKey,
payload: &PingResponsePayload,
) -> PingResponse
pub fn new( shared_secret: &PrecomputedKey, pk: &PublicKey, payload: &PingResponsePayload, ) -> PingResponse
create new PingResponse object
Sourcepub fn get_payload(
&self,
shared_secret: &PrecomputedKey,
) -> Result<PingResponsePayload, GetPayloadError>
pub fn get_payload( &self, shared_secret: &PrecomputedKey, ) -> Result<PingResponsePayload, GetPayloadError>
Decrypt payload and try to parse it as PingResponsePayload
.
Returns Error
in case of failure:
- fails to decrypt
- fails to parse as given packet type
Trait Implementations§
Source§impl Clone for PingResponse
impl Clone for PingResponse
Source§fn clone(&self) -> PingResponse
fn clone(&self) -> PingResponse
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for PingResponse
impl Debug for PingResponse
Source§impl FromBytes for PingResponse
impl FromBytes for PingResponse
Source§fn from_bytes(i: &[u8]) -> IResult<&[u8], PingResponse, (&[u8], ErrorKind)>
fn from_bytes(i: &[u8]) -> IResult<&[u8], PingResponse, (&[u8], ErrorKind)>
Deserialize struct using
nom
from raw bytesSource§impl PartialEq for PingResponse
impl PartialEq for PingResponse
Source§impl ToBytes for PingResponse
impl ToBytes for PingResponse
impl Eq for PingResponse
impl StructuralPartialEq for PingResponse
Auto Trait Implementations§
impl Freeze for PingResponse
impl RefUnwindSafe for PingResponse
impl Send for PingResponse
impl Sync for PingResponse
impl Unpin for PingResponse
impl UnwindSafe for PingResponse
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
Mutably borrows from an owned value. Read more