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 PartialOrd for VlanPcp
impl PartialOrd for VlanPcp
impl Copy for VlanPcp
impl Eq for VlanPcp
impl StructuralPartialEq for VlanPcp
Auto Trait Implementations§
impl Freeze for VlanPcp
impl RefUnwindSafe for VlanPcp
impl Send for VlanPcp
impl Sync for VlanPcp
impl Unpin for VlanPcp
impl UnwindSafe for VlanPcp
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)