[][src]Struct cjdns_sniff::CtrlMessage

pub struct CtrlMessage {
    pub msg_type: CtrlMessageType,
    pub msg_data: CtrlMessageData,
}

Serialized control message

Fields

msg_type: CtrlMessageTypemsg_data: CtrlMessageData

Implementations

impl CtrlMessage[src]

pub const HEADER_SIZE: usize[src]

Control message header size, which is considered as minimum size message bytes to parsed. Actually, message size should be greater than is stated in this constant, but this is checked further in CtrlMessage "sub-parsers".

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

Parses raw bytes into CtrlMessage.

Result in error in several situations:

  • input bytes length is less then CtrlMessage::HEADER_SIZE
  • input data got invalid checksum
  • unrecognized control message type code was parsed
  • control message body parsing methods failed. For more information about this read documentation for corresponding message data structs (i.e. PingData, ErrorData)

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

Serializes CtrlMessage instance.

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

  • instantiated message with different header and body types. For example, message with error type stated in header and ping data will fail serialization
  • error/ping data serialization failed

pub fn get_error_data(&self) -> Option<&ErrorData>[src]

pub fn get_ping_data(&self) -> Option<&PingData>[src]

Trait Implementations

impl Clone for CtrlMessage[src]

impl Debug for CtrlMessage[src]

impl Eq for CtrlMessage[src]

impl PartialEq<CtrlMessage> for CtrlMessage[src]

impl StructuralEq for CtrlMessage[src]

impl StructuralPartialEq for CtrlMessage[src]

Auto Trait Implementations

impl RefUnwindSafe for CtrlMessage

impl Send for CtrlMessage

impl Sync for CtrlMessage

impl Unpin for CtrlMessage

impl UnwindSafe for CtrlMessage

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<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,