pub struct IpDscp(/* private fields */);Expand description
6 bit unsigned integer containing the “Differentiated Services
Code Point” (present in the crate::Ipv4Header and in the
in crate::Ipv6Header as part of traffic_class).
Established in RFC-2472 and defined/maintained in the IANA dscp-registry
Implementations§
Source§impl IpDscp
impl IpDscp
Sourcepub const VOICE_ADMIT: IpDscp
pub const VOICE_ADMIT: IpDscp
Voice admit (Pool 1) RFC-5865
Sourcepub const LOWER_EFFORT: IpDscp
pub const LOWER_EFFORT: IpDscp
Lower Effort PHB (Pool 3) RFC-8622
Sourcepub const fn try_new(value: u8) -> Result<IpDscp, ValueTooBigError<u8>>
pub const fn try_new(value: u8) -> Result<IpDscp, ValueTooBigError<u8>>
Tries to create an IpDscp and checks that the passed value
is smaller or equal than IpDscp::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 IpDscp.
use etherparse::IpDscp;
let dscp = IpDscp::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!(
IpDscp::try_new(IpDscp::MAX_U8 + 1),
Err(ValueTooBigError{
actual: IpDscp::MAX_U8 + 1,
max_allowed: IpDscp::MAX_U8,
value_type: ValueType::IpDscp,
})
);Sourcepub const unsafe fn new_unchecked(value: u8) -> IpDscp
pub const unsafe fn new_unchecked(value: u8) -> IpDscp
Creates an IpDscp without checking that the value
is smaller or equal than IpDscp::MAX_U8 (6 bit unsigned integer).
The caller must guarantee that value <= IpDscp::MAX_U8.
§Safety
value must be smaller or equal than IpDscp::MAX_U8
otherwise the behavior of functions or data structures relying
on this pre-requirement is undefined.