[][src]Struct cjdns_ctrl::PingData

pub struct PingData {
    pub version: u32,
    pub key: Option<CJDNSPublicKey>,
    pub content: Vec<u8>,
}

Body data for ping type control messages

Fields

version: u32key: Option<CJDNSPublicKey>content: Vec<u8>

Implementations

impl PingData[src]

pub const MIN_SIZE: usize[src]

Minimum ping data size

pub fn parse(bytes: &[u8], ping: CtrlMessageType) -> Result<Self, ParseError>[src]

Parses raw bytes into PingData.

Result in error in several situations:

  • input bytes length is less than PingData::MIN_SIZE
  • encoded ping magic is not equal to magic defined for the inputted ping
  • if input ping is sort of key pings, but bytes data size is too small to create cjdns public key from it

pub fn serialize(
    &self,
    ping: CtrlMessageType
) -> Result<Vec<u8>, SerializeError>
[src]

Serialized PingData instance.

PingData type can be instantiated directly, without using parse method. That's why serialization can result in errors in several situations:

  • instance has version of 0
  • ping variable, which is defined by control message serialize method, has key ping/pong type, but key is not specified in the data instance

Trait Implementations

impl Clone for PingData[src]

impl Debug for PingData[src]

impl Eq for PingData[src]

impl PartialEq<PingData> for PingData[src]

impl StructuralEq for PingData[src]

impl StructuralPartialEq for PingData[src]

Auto Trait Implementations

impl RefUnwindSafe for PingData

impl Send for PingData

impl Sync for PingData

impl Unpin for PingData

impl UnwindSafe for PingData

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.