Struct rtnetlink::proto::NetlinkMessage
[−]pub struct NetlinkMessage<I> {
pub header: NetlinkHeader,
pub payload: NetlinkPayload<I>,
}
Expand description
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>
impl<I> NetlinkMessage<I>
pub fn new(
header: NetlinkHeader,
payload: NetlinkPayload<I>
) -> NetlinkMessage<I>
pub fn new(
header: NetlinkHeader,
payload: NetlinkPayload<I>
) -> NetlinkMessage<I>
Create a new netlink message from the given header and payload
pub fn into_parts(self) -> (NetlinkHeader, NetlinkPayload<I>)
pub fn into_parts(self) -> (NetlinkHeader, NetlinkPayload<I>)
Consume this message and return its header and payload
impl<I> NetlinkMessage<I> where
I: NetlinkDeserializable,
impl<I> NetlinkMessage<I> where
I: NetlinkDeserializable,
pub fn deserialize(buffer: &[u8]) -> Result<NetlinkMessage<I>, DecodeError>
pub fn deserialize(buffer: &[u8]) -> Result<NetlinkMessage<I>, DecodeError>
Parse the given buffer as a netlink message
impl<I> NetlinkMessage<I> where
I: NetlinkSerializable,
impl<I> NetlinkMessage<I> where
I: NetlinkSerializable,
pub fn buffer_len(&self) -> usize
pub fn buffer_len(&self) -> usize
Return the length of this message in bytes
pub fn serialize(&self, buffer: &mut [u8])
pub fn serialize(&self, buffer: &mut [u8])
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)
pub fn finalize(&mut self)
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,
impl<I> Clone for NetlinkMessage<I> where
I: Clone,
fn clone(&self) -> NetlinkMessage<I>
fn clone(&self) -> NetlinkMessage<I>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<I> Debug for NetlinkMessage<I> where
I: Debug,
impl<I> Debug for NetlinkMessage<I> where
I: Debug,
impl<I> Emitable for NetlinkMessage<I> where
I: NetlinkSerializable,
impl<I> Emitable for NetlinkMessage<I> where
I: NetlinkSerializable,
fn buffer_len(&self) -> usize
fn buffer_len(&self) -> usize
Return the length of the serialized data.
impl<T> From<T> for NetlinkMessage<T> where
T: Into<NetlinkPayload<T>>,
impl<T> From<T> for NetlinkMessage<T> where
T: Into<NetlinkPayload<T>>,
fn from(inner_message: T) -> NetlinkMessage<T>
fn from(inner_message: T) -> NetlinkMessage<T>
Converts to this type from the input type.
impl<'buffer, B, I> Parseable<NetlinkBuffer<&'buffer B>> for NetlinkMessage<I> where
B: 'buffer + AsRef<[u8]>,
I: NetlinkDeserializable,
impl<'buffer, B, I> Parseable<NetlinkBuffer<&'buffer B>> for NetlinkMessage<I> where
B: 'buffer + AsRef<[u8]>,
I: NetlinkDeserializable,
fn parse(
buf: &NetlinkBuffer<&'buffer B>
) -> Result<NetlinkMessage<I>, DecodeError>
fn parse(
buf: &NetlinkBuffer<&'buffer B>
) -> Result<NetlinkMessage<I>, DecodeError>
Deserialize the current type.
impl<I> PartialEq<NetlinkMessage<I>> for NetlinkMessage<I> where
I: PartialEq<I>,
impl<I> PartialEq<NetlinkMessage<I>> for NetlinkMessage<I> where
I: PartialEq<I>,
fn eq(&self, other: &NetlinkMessage<I>) -> bool
fn eq(&self, other: &NetlinkMessage<I>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &NetlinkMessage<I>) -> bool
fn ne(&self, other: &NetlinkMessage<I>) -> bool
This method tests for !=
.
impl<I> Eq for NetlinkMessage<I> where
I: Eq,
impl<I> StructuralEq for NetlinkMessage<I>
impl<I> StructuralPartialEq for NetlinkMessage<I>
Auto Trait Implementations
impl<I> RefUnwindSafe for NetlinkMessage<I> where
I: RefUnwindSafe,
impl<I> Send for NetlinkMessage<I> where
I: Send,
impl<I> Sync for NetlinkMessage<I> where
I: Sync,
impl<I> Unpin for NetlinkMessage<I> where
I: Unpin,
impl<I> UnwindSafe for NetlinkMessage<I> where
I: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more