[][src]Struct domain::base::serial::Serial

pub struct Serial(pub u32);

A serial number.

Serial numbers are used in DNS to track changes to resources. For instance, the [Soa] record type provides a serial number that expresses the version of the zone. Since these numbers are only 32 bits long, they can wrap. RFC 1982 defined the semantics for doing arithmetics in the face of these wrap-arounds. This type implements these semantics atop a native u32.

The RFC defines two operations: addition and comparison.

For addition, the amount added can only be a positive number of up to 2^31 - 1. Because of this, 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.

Implementations

impl Serial[src]

pub fn now() -> Self[src]

Returns a serial number for the current Unix time.

pub fn into_int(self) -> u32[src]

Returns the serial number as a raw integer.

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

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

impl CanonicalOrd<Serial> for Serial[src]

impl Clone for Serial[src]

impl Compose for Serial[src]

impl Copy for Serial[src]

impl Debug for Serial[src]

impl Display for Serial[src]

impl Eq for Serial[src]

impl From<Serial> for u32[src]

impl From<u32> for Serial[src]

impl FromStr for Serial[src]

type Err = <u32 as FromStr>::Err

The associated error which can be returned from parsing.

impl Hash for Serial[src]

impl<T: AsRef<[u8]>> Parse<T> for Serial[src]

impl PartialEq<Serial> for Serial[src]

impl PartialOrd<Serial> for Serial[src]

impl StructuralEq for Serial[src]

impl StructuralPartialEq for Serial[src]

Auto Trait Implementations

impl RefUnwindSafe for Serial

impl Send for Serial

impl Sync for Serial

impl Unpin for Serial

impl UnwindSafe for Serial

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,