pub trait Attribute<T> {
// Required methods
fn payload(&self) -> &Buffer;
fn set_payload<P>(&mut self, payload: &P) -> Result<(), SerError>
where P: Size + ToBytes;
// Provided methods
fn get_payload_as<'a, R>(&'a self) -> Result<R, DeError>
where R: FromBytes<'a> { ... }
fn get_payload_as_with_len<'a, R>(&'a self) -> Result<R, DeError>
where R: FromBytesWithInput<'a, Input = usize> { ... }
}
Expand description
Trait that defines shared operations for netlink attributes. Currently, this applies to generic netlink and routing netlink attributes.
Required Methods§
Sourcefn payload(&self) -> &Buffer
fn payload(&self) -> &Buffer
Get the payload of the given attribute.
Due to Rust’s requirement that all elements of a Vec
are of
the same type, payloads are represented as a byte buffer so
that nested attributes that contain multiple types for the
payload can be type checked before serialization yet still
contained all in the same top level attribute.
Provided Methods§
Sourcefn get_payload_as<'a, R>(&'a self) -> Result<R, DeError>where
R: FromBytes<'a>,
fn get_payload_as<'a, R>(&'a self) -> Result<R, DeError>where
R: FromBytes<'a>,
Get an Nlattr
payload as the
provided type parameter, R
.
Sourcefn get_payload_as_with_len<'a, R>(&'a self) -> Result<R, DeError>where
R: FromBytesWithInput<'a, Input = usize>,
fn get_payload_as_with_len<'a, R>(&'a self) -> Result<R, DeError>where
R: FromBytesWithInput<'a, Input = usize>,
Get an Nlattr
payload as the
provided type parameter, R
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.