Struct rpki::rtr::state::Serial

source ·
pub struct Serial(pub u32);
Expand description

A serial number.

Serial numbers are regular integers with a special notion for comparison in order to be able to deal with roll-over.

Specifically, addition and comparison are defined in RFC 1982. Addition, however, is only defined for values up to 2^31 - 1, so we decided to not implement the Add trait but rather have a dedicated method add so as to not cause surprise panics.

Serial numbers only implement a partial ordering. That is, there are pairs of values that are not equal but there still isn’t one value larger than the other. Since this is neatly implemented by the PartialOrd trait, the type implements that.

Tuple Fields§

§0: u32

Implementations§

source§

impl Serial

source

pub const fn from_be(value: u32) -> Self

source

pub const fn to_be(self) -> u32

source

pub fn add(self, other: u32) -> Self

Add other to self.

Serial numbers only allow values of up to 2^31 - 1 to be added to them. Therefore, this method requires other to be a u32 instead of a Serial to indicate that you cannot simply add two serials together. This is also why we don’t implement the Add trait.

§Panics

This method panics if other is greater than 2^31 - 1.

Trait Implementations§

source§

impl<'arbitrary> Arbitrary<'arbitrary> for Serial

source§

fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
source§

fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
source§

impl Clone for Serial

source§

fn clone(&self) -> Serial

Returns a copy 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 Serial

source§

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

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

impl Default for Serial

source§

fn default() -> Self

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

impl Display for Serial

source§

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

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

impl From<Serial> for u32

source§

fn from(serial: Serial) -> u32

Converts to this type from the input type.
source§

impl From<u32> for Serial

source§

fn from(value: u32) -> Serial

Converts to this type from the input type.
source§

impl FromStr for Serial

§

type Err = <u32 as FromStr>::Err

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for Serial

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 PartialEq<u32> for Serial

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq for Serial

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Serial

source§

fn partial_cmp(&self, other: &Serial) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for Serial

source§

impl Eq for Serial

Auto Trait Implementations§

§

impl Freeze for Serial

§

impl RefUnwindSafe for Serial

§

impl Send for Serial

§

impl Sync for Serial

§

impl Unpin for Serial

§

impl UnwindSafe for Serial

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> 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> Text for T
where T: Display,

source§

fn write_escaped( &self, mode: TextEscape, target: &mut impl Write, ) -> Result<(), Error>

Write text escaped for the given mode to target.
source§

fn write_raw(&self, target: &mut impl Write) -> Result<(), Error>

Write text as is to target.
source§

fn write_base64(&self, target: &mut impl Write) -> Result<(), Error>

Write text encoded in BASE64 to target.
source§

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

§

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§

default 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>,

§

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>,

§

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.