Struct etherparse::Ipv4Dscp
source · pub struct Ipv4Dscp(/* private fields */);
Expand description
6 bit unsigned integer containing the “Differentiated Services
Code Point” (present in the crate::Ipv4Header
).
Implementations§
source§impl Ipv4Dscp
impl Ipv4Dscp
sourcepub const fn try_new(value: u8) -> Result<Ipv4Dscp, ValueTooBigError<u8>>
pub const fn try_new(value: u8) -> Result<Ipv4Dscp, ValueTooBigError<u8>>
Tries to create an Ipv4Dscp
and checks that the passed value
is smaller or equal than Ipv4Dscp::MAX_U8
(6 bit unsigned integer).
In case the passed value is bigger then what can be represented in an 6 bit
integer an error is returned. Otherwise an Ok
containing the Ipv4Dscp
.
use etherparse::Ipv4Dscp;
let dscp = Ipv4Dscp::try_new(32).unwrap();
assert_eq!(dscp.value(), 32);
// if a number that can not be represented in an 6 bit integer
// gets passed in an error is returned
use etherparse::err::{ValueTooBigError, ValueType};
assert_eq!(
Ipv4Dscp::try_new(Ipv4Dscp::MAX_U8 + 1),
Err(ValueTooBigError{
actual: Ipv4Dscp::MAX_U8 + 1,
max_allowed: Ipv4Dscp::MAX_U8,
value_type: ValueType::Ipv4Dscp,
})
);
sourcepub const unsafe fn new_unchecked(value: u8) -> Ipv4Dscp
pub const unsafe fn new_unchecked(value: u8) -> Ipv4Dscp
Creates an Ipv4Dscp
without checking that the value
is smaller or equal than Ipv4Dscp::MAX_U8
(6 bit unsigned integer).
The caller must guarantee that value <= Ipv4Dscp::MAX_U8
.
§Safety
value
must be smaller or equal than Ipv4Dscp::MAX_U8
otherwise the behavior of functions or data structures relying
on this pre-requirement is undefined.
Trait Implementations§
source§impl Ord for Ipv4Dscp
impl Ord for Ipv4Dscp
source§impl PartialEq for Ipv4Dscp
impl PartialEq for Ipv4Dscp
source§impl PartialOrd for Ipv4Dscp
impl PartialOrd for Ipv4Dscp
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Ipv4Dscp
impl Eq for Ipv4Dscp
impl StructuralPartialEq for Ipv4Dscp
Auto Trait Implementations§
impl Freeze for Ipv4Dscp
impl RefUnwindSafe for Ipv4Dscp
impl Send for Ipv4Dscp
impl Sync for Ipv4Dscp
impl Unpin for Ipv4Dscp
impl UnwindSafe for Ipv4Dscp
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
Mutably borrows from an owned value. Read more