Struct etherparse::VlanPcp
source · pub struct VlanPcp(/* private fields */);
Expand description
3 bit unsigned integer containing the “Priority Code Point”
(present in the crate::SingleVlanHeader
).
Refers to the IEEE 802.1p class of service and maps to the frame priority level.
Implementations§
source§impl VlanPcp
impl VlanPcp
sourcepub const fn try_new(value: u8) -> Result<VlanPcp, ValueTooBigError<u8>>
pub const fn try_new(value: u8) -> Result<VlanPcp, ValueTooBigError<u8>>
Tries to create an VlanPcp
and checks that the passed value
is smaller or equal than VlanPcp::MAX_U8
(3 bit unsigned integer).
In case the passed value is bigger then what can be represented in an 3 bit
integer an error is returned. Otherwise an Ok
containing the VlanPcp
.
use etherparse::VlanPcp;
let pcp = VlanPcp::try_new(2).unwrap();
assert_eq!(pcp.value(), 2);
// if a number that can not be represented in an 3 bit integer
// gets passed in an error is returned
use etherparse::err::{ValueTooBigError, ValueType};
assert_eq!(
VlanPcp::try_new(VlanPcp::MAX_U8 + 1),
Err(ValueTooBigError{
actual: VlanPcp::MAX_U8 + 1,
max_allowed: VlanPcp::MAX_U8,
value_type: ValueType::VlanPcp,
})
);
sourcepub const unsafe fn new_unchecked(value: u8) -> VlanPcp
pub const unsafe fn new_unchecked(value: u8) -> VlanPcp
Creates an VlanPcp
without checking that the value
is smaller or equal than VlanPcp::MAX_U8
(3 bit unsigned integer).
The caller must guarantee that value <= VlanPcp::MAX_U8
.
§Safety
value
must be smaller or equal than VlanPcp::MAX_U8
otherwise the behavior of functions or data structures relying
on this pre-requirement is undefined.
Trait Implementations§
source§impl Ord for VlanPcp
impl Ord for VlanPcp
source§impl PartialEq for VlanPcp
impl PartialEq for VlanPcp
source§impl PartialOrd for VlanPcp
impl PartialOrd for VlanPcp
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more