Struct uapi::NlmsgWriter

source ·
pub struct NlmsgWriter<'a, H: NlmsgHeader = ()> { /* private fields */ }
👎Deprecated: beta features are subject to change at any time
Expand description

A writer for netlink messages

See also the crate documentation.

Implementations§

source§

impl<'a, H: NlmsgHeader> NlmsgWriter<'a, H>

source

pub fn new<T: Pod + ?Sized>(buf: &'a mut T, header: H) -> Result<Self>

Creates a new writer that uses the buffer as backing storage

source

pub fn write<T: ?Sized>(&mut self, data: &T) -> Result<()>

Writes an object to the buffer

This involves three steps:

  • The write position is aligned to the next 4 byte boundary
  • The object is written
  • The write position is advanced by the size of the object

Returns an error if the buffer does not contain enough space.

source

pub fn nest<H2: NlmsgHeader>( &mut self, header: H2 ) -> Result<NlmsgWriter<'_, H2>>

Nests a new message within the write buffer

Returns an error if there is not enough space to write the header at the next 4 byte boundary.

When the nested writer is dropped, the behavior is as if the nested message had been written to a separate buffer and then written to this writer using Self::write.

source

pub fn finalize(self) -> Result<&'a mut [u8]>

Sets the length field of the header to the correct value

This function returns an error if [NlmsgHeader::set_len] fails.

Trait Implementations§

source§

impl<'a, H: NlmsgHeader> Drop for NlmsgWriter<'a, H>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, H> Freeze for NlmsgWriter<'a, H>
where H: Freeze,

§

impl<'a, H> RefUnwindSafe for NlmsgWriter<'a, H>
where H: RefUnwindSafe,

§

impl<'a, H> Send for NlmsgWriter<'a, H>
where H: Send,

§

impl<'a, H> Sync for NlmsgWriter<'a, H>
where H: Sync,

§

impl<'a, H> Unpin for NlmsgWriter<'a, H>
where H: Unpin,

§

impl<'a, H = ()> !UnwindSafe for NlmsgWriter<'a, H>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.