#[repr(u8)]pub enum IpEcn {
NotEct = 0,
Ect1 = 1,
Ect0 = 2,
CongestionExperienced = 3,
}Expand description
Code points for “Explicit Congestion Notification” (ECN) present in the
crate::Ipv4Header and crate::Ipv6Header.
Code points are defined in RFC-3168
For reasoning to why there are two code points with the exact same meaning, see RFC-3168 Section 20.2
Variants§
NotEct = 0
End node is not an ECN capable transport.
Ect1 = 1
End node is an ECN capable transport (experimental).
Ect0 = 2
End node is an ECN capable transport.
CongestionExperienced = 3
Congestion is experienced by the router.
Implementations§
Source§impl IpEcn
impl IpEcn
Sourcepub const TRHEE: IpEcn = IpEcn::THREE
👎Deprecated since 0.18.0: Please use IpEcn::THREE instead.
pub const TRHEE: IpEcn = IpEcn::THREE
Deprecated, use crate::IpEcn::THREE instead.
Sourcepub const fn try_new(value: u8) -> Result<IpEcn, ValueTooBigError<u8>>
pub const fn try_new(value: u8) -> Result<IpEcn, ValueTooBigError<u8>>
Tries to create an IpEcn and checks that the passed value
is smaller or equal than IpEcn::MAX_U8 (2 bit unsigned integer).
In case the passed value is bigger then what can be represented in an 2 bit
integer an error is returned. Otherwise an Ok containing the IpEcn.
use etherparse::IpEcn;
let ecn = IpEcn::try_new(2).unwrap();
assert_eq!(ecn.value(), 2);
// if a number that can not be represented in an 2 bit integer
// gets passed in an error is returned
use etherparse::err::{ValueTooBigError, ValueType};
assert_eq!(
IpEcn::try_new(IpEcn::MAX_U8 + 1),
Err(ValueTooBigError{
actual: IpEcn::MAX_U8 + 1,
max_allowed: IpEcn::MAX_U8,
value_type: ValueType::IpEcn,
})
);Sourcepub const unsafe fn new_unchecked(value: u8) -> IpEcn
pub const unsafe fn new_unchecked(value: u8) -> IpEcn
Creates an IpEcn without checking that the value
is smaller or equal than IpEcn::MAX_U8 (2 bit unsigned integer).
The caller must guarantee that value <= IpEcn::MAX_U8.
§Safety
value must be smaller or equal than IpEcn::MAX_U8
otherwise the behavior of functions or data structures relying
on this pre-requirement is undefined.