[][src]Trait netlink_packet_core::NetlinkSerializable

pub trait NetlinkSerializable<T> {
    pub fn message_type(&self) -> u16;
pub fn buffer_len(&self) -> usize;
pub fn serialize(&self, buffer: &mut [u8]); }

Required methods

pub fn message_type(&self) -> u16[src]

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

Return the length of the serialized data.

Most netlink messages are encoded following a TLV scheme and this library takes advantage of this by pre-allocating buffers of the appropriate size when serializing messages, which is why buffer_len is needed.

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

Serialize this types and write the serialized data into the given buffer. buffer's length is exactly InnerMessage::buffer_len(). It means that if InnerMessage::buffer_len() is buggy and does not return the appropriate length, bad things can happen:

  • if buffer_len() returns a value smaller than the actual data, emit() may panics
  • if buffer_len() returns a value bigger than the actual data, the buffer will contain garbage

Panic

This method panics if the buffer is not big enough.

Loading content...

Implementors

Loading content...