[][src]Struct netlink_packet_route::NetlinkMessage

pub struct NetlinkMessage<I> where
    I: Debug + PartialEq<I> + Eq + Clone
{ pub header: NetlinkHeader, pub payload: NetlinkPayload<I>, }

Represent a netlink message.

Fields

header: NetlinkHeader

Message header (this is common to all the netlink protocols)

payload: NetlinkPayload<I>

Inner message, which depends on the netlink protocol being used.

Implementations

impl<I> NetlinkMessage<I> where
    I: Debug + PartialEq<I> + Eq + Clone
[src]

pub fn new(
    header: NetlinkHeader,
    payload: NetlinkPayload<I>
) -> NetlinkMessage<I>
[src]

Create a new netlink message from the given header and payload

pub fn into_parts(self) -> (NetlinkHeader, NetlinkPayload<I>)[src]

Consume this message and return its header and payload

impl<I> NetlinkMessage<I> where
    I: NetlinkDeserializable<I> + Debug + PartialEq<I> + Eq + Clone
[src]

pub fn deserialize(buffer: &[u8]) -> Result<NetlinkMessage<I>, DecodeError>[src]

Parse the given buffer as a netlink message

impl<I> NetlinkMessage<I> where
    I: NetlinkSerializable<I> + Debug + PartialEq<I> + Eq + Clone
[src]

pub fn buffer_len(&self) -> usize[src]

Return the length of this message in bytes

pub fn serialize(&self, buffer: &mut [u8])[src]

Serialize this message and write the serialized data into the given buffer. buffer must big large enough for the whole message to fit, otherwise, this method will panic. To know how big the serialized message is, call buffer_len().

Panic

This method panics if the buffer is not big enough.

pub fn finalize(&mut self)[src]

Ensure the header (NetlinkHeader) is consistent with the payload (NetlinkPayload):

  • compute the payload length and set the header's length field
  • check the payload type and set the header's message type field accordingly

If you are not 100% sure the header is correct, this method should be called before calling Emitable::emit(), as it could panic if the header is inconsistent with the rest of the message.

Trait Implementations

impl<I> Clone for NetlinkMessage<I> where
    I: Clone + Debug + PartialEq<I> + Eq
[src]

impl<I> Debug for NetlinkMessage<I> where
    I: Debug + PartialEq<I> + Eq + Clone
[src]

impl<I> Emitable for NetlinkMessage<I> where
    I: NetlinkSerializable<I> + Debug + PartialEq<I> + Eq + Clone
[src]

impl<I> Eq for NetlinkMessage<I> where
    I: Eq + Debug + PartialEq<I> + Clone
[src]

impl<T> From<T> for NetlinkMessage<T> where
    T: Into<NetlinkPayload<T>> + Debug + Clone + Eq + PartialEq<T>, 
[src]

impl<'buffer, B, I> Parseable<NetlinkBuffer<&'buffer B>> for NetlinkMessage<I> where
    I: Debug + PartialEq<I> + Eq + Clone + NetlinkDeserializable<I>,
    B: AsRef<[u8]> + 'buffer, 
[src]

impl<I> PartialEq<NetlinkMessage<I>> for NetlinkMessage<I> where
    I: PartialEq<I> + Debug + Eq + Clone
[src]

impl<I> StructuralEq for NetlinkMessage<I> where
    I: Debug + PartialEq<I> + Eq + Clone
[src]

impl<I> StructuralPartialEq for NetlinkMessage<I> where
    I: Debug + PartialEq<I> + Eq + Clone
[src]

Auto Trait Implementations

impl<I> RefUnwindSafe for NetlinkMessage<I> where
    I: RefUnwindSafe
[src]

impl<I> Send for NetlinkMessage<I> where
    I: Send
[src]

impl<I> Sync for NetlinkMessage<I> where
    I: Sync
[src]

impl<I> Unpin for NetlinkMessage<I> where
    I: Unpin
[src]

impl<I> UnwindSafe for NetlinkMessage<I> where
    I: UnwindSafe
[src]

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.