Attribute

Struct Attribute 

Source
pub struct Attribute {
    pub identifier: u16,
    /* private fields */
}
Expand description

Netlink attribute

| length | identifier |        data        | padding |
|--------|------------|--------------------|---------|
|   u16  |     u16    |  u8 * (length - 4) |         |

The data is 4 byte aligned.

Fields§

§identifier: u16

Attribute identifier

Implementations§

Source§

impl Attribute

Source

pub fn unpack_all(data: &[u8]) -> (usize, Vec<Attribute>)

Unpack all attributes in the byte slice

Source

pub fn new_bytes<ID: Into<u16>>(identifier: ID, value: &[u8]) -> Attribute

Create a new string attribute with provided identifier

Source

pub fn new_string_with_nul<ID: Into<u16>>( identifier: ID, value: &str, ) -> Attribute

Create a new string attribute with provided identifier

Source

pub fn new_string<ID: Into<u16>>(identifier: ID, value: &str) -> Attribute

Create a new string attribute with provided identifier

Source

pub fn new<ID: Into<u16>, V: NativePack>(identifier: ID, value: V) -> Attribute

Create a new attribute from a type that can be packed into a byte slice

Source

pub fn len(&self) -> u16

Get the length of the data

Source

pub fn total_len(&self) -> usize

Get the length of the data and header

Source

pub fn as_u8(&self) -> Result<u8>

Unpack the underlying data into a u8

Source

pub fn as_u16(&self) -> Result<u16>

Unpack the underlying data into a u16

Source

pub fn as_u32(&self) -> Result<u32>

Unpack the underlying data into a u32

Source

pub fn as_u64(&self) -> Result<u64>

Unpack the underlying data into a u64

Source

pub fn as_i8(&self) -> Result<i8>

Unpack the underlying data into a i8

Source

pub fn as_i16(&self) -> Result<i16>

Unpack the underlying data into a i16

Source

pub fn as_i32(&self) -> Result<i32>

Unpack the underlying data into a i32

Source

pub fn as_i64(&self) -> Result<i64>

Unpack the underlying data into a i64

Source

pub fn as_string(&self) -> Result<String>

Unpack the underlying data into a String

Source

pub fn as_hardware_address(&self) -> Result<HardwareAddress>

Unpack the underlying data into a HardwareAddress

Source

pub fn as_bytes(&self) -> Vec<u8>

Get a clone of the underlying data

Trait Implementations§

Source§

impl Clone for Attribute

Source§

fn clone(&self) -> Attribute

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl NativePack for Attribute

Source§

fn pack_size(&self) -> usize

Source§

fn pack<'a>(&self, buffer: &'a mut [u8]) -> Result<&'a mut [u8]>

Pack value into byte slice, returning the unused part of the slice
Source§

fn pack_unchecked(&self, buffer: &mut [u8])

Pack value into slice without failing
Source§

impl NativeUnpack for Attribute

Source§

fn unpack_with_size(buffer: &[u8]) -> Result<(usize, Self)>

Unpack byte slice into value, also returning size used
Source§

fn unpack_unchecked(buffer: &[u8]) -> Self

Unpack byte slice into value without failing
Source§

fn unpack(buffer: &[u8]) -> Result<Self>

Unpack byte slice into value

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.