IpDscp

Struct IpDscp 

Source
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

Source

pub const ZERO: IpDscp

IpDscp with value 0.

Source

pub const MAX_U8: u8 = 63u8

Maximum value of an IPv4 header DSCP.

Source

pub const MAX: IpDscp

Maximum value of DSCP field (6 bits).

Source

pub const CS0: IpDscp

Class Selector 0 (Pool 1) RFC-2474

Source

pub const CS1: IpDscp

Class Selector 1 (Pool 1) RFC-2474

Source

pub const CS2: IpDscp

Class Selector 2 (Pool 1) RFC-2474

Source

pub const CS3: IpDscp

Class Selector 3 (Pool 1) RFC-2474

Source

pub const CS4: IpDscp

Class Selector 4 (Pool 1) RFC-2474

Source

pub const CS5: IpDscp

Class Selector 5 (Pool 1) RFC-2474

Source

pub const CS6: IpDscp

Class Selector 6 (Pool 1) RFC-2474

Source

pub const CS7: IpDscp

Class Selector 7 (Pool 1) RFC-2474

Source

pub const AF11: IpDscp

Assured Forwarding PHB Group 11 (Pool 1) RFC-2597

Source

pub const AF12: IpDscp

Assured Forwarding PHB Group 12 (Pool 1) RFC-2597

Source

pub const AF13: IpDscp

Assured Forwarding PHB Group 13 (Pool 1) RFC-2597

Source

pub const AF21: IpDscp

Assured Forwarding PHB Group 21 (Pool 1) RFC-2597

Source

pub const AF22: IpDscp

Assured Forwarding PHB Group 22 (Pool 1) RFC-2597

Source

pub const AF23: IpDscp

Assured Forwarding PHB Group 23 (Pool 1) RFC-2597

Source

pub const AF31: IpDscp

Assured Forwarding PHB Group 31 (Pool 1) RFC-2597

Source

pub const AF32: IpDscp

Assured Forwarding PHB Group 32 (Pool 1) RFC-2597

Source

pub const AF33: IpDscp

Assured Forwarding PHB Group 11 (Pool 1) RFC-2597

Source

pub const AF41: IpDscp

Assured Forwarding PHB Group 11 (Pool 1) RFC-2597

Source

pub const AF42: IpDscp

Assured Forwarding PHB Group 11 (Pool 1) RFC-2597

Source

pub const AF43: IpDscp

Assured Forwarding PHB Group 11 (Pool 1) RFC-2597

Source

pub const EF: IpDscp

Expedited Forwarding (Pool 1) RFC-3246

Source

pub const VOICE_ADMIT: IpDscp

Voice admit (Pool 1) RFC-5865

Source

pub const LOWER_EFFORT: IpDscp

Lower Effort PHB (Pool 3) RFC-8622

Source

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,
    })
);
Source

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.

Source

pub const fn value(self) -> u8

Returns the underlying unsigned 6 bit value as an u8 value.

Trait Implementations§

Source§

impl Clone for IpDscp

Source§

fn clone(&self) -> IpDscp

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IpDscp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for IpDscp

Source§

fn default() -> IpDscp

Returns the “default value” for a type. Read more
Source§

impl Display for IpDscp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<IpDscp> for u8

Source§

fn from(value: IpDscp) -> Self

Converts to this type from the input type.
Source§

impl From<IpDscpKnown> for IpDscp

Source§

fn from(value: IpDscpKnown) -> Self

Converts to this type from the input type.
Source§

impl Hash for IpDscp

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for IpDscp

Source§

fn cmp(&self, other: &IpDscp) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for IpDscp

Source§

fn eq(&self, other: &IpDscp) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for IpDscp

Source§

fn partial_cmp(&self, other: &IpDscp) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl TryFrom<IpDscp> for IpDscpKnown

Source§

type Error = IpDscpUnknownValueError

The type returned in the event of a conversion error.
Source§

fn try_from(value: IpDscp) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<u8> for IpDscp

Source§

type Error = ValueTooBigError<u8>

The type returned in the event of a conversion error.
Source§

fn try_from(value: u8) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for IpDscp

Source§

impl Eq for IpDscp

Source§

impl StructuralPartialEq for IpDscp

Auto Trait Implementations§

§

impl Freeze for IpDscp

§

impl RefUnwindSafe for IpDscp

§

impl Send for IpDscp

§

impl Sync for IpDscp

§

impl Unpin for IpDscp

§

impl UnwindSafe for IpDscp

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.