pub struct Serial(pub u32);
Expand description
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.
Tuple Fields§
§0: u32
Implementations§
source§impl Serial
impl Serial
sourcepub fn from_be_bytes(bytes: [u8; 4]) -> Self
pub fn from_be_bytes(bytes: [u8; 4]) -> Self
Creates a new serial number from its octets in big endian notation.
sourcepub fn add(self, other: u32) -> Self
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
.
pub fn scan<S: Scanner>(scanner: &mut S) -> Result<Self, S::Error>
sourcepub fn scan_rrsig<S: Scanner>(scanner: &mut S) -> Result<Self, S::Error>
pub fn scan_rrsig<S: Scanner>(scanner: &mut S) -> Result<Self, S::Error>
Scan a serial represention signature time value.
In RRSIG records, the expiration and inception times are given as
serial values. Their representation format can either be the
value or a specific date in YYYYMMDDHHmmSS
format.
sourcepub fn rrsig_from_str(src: &str) -> Result<Self, IllegalSignatureTime>
pub fn rrsig_from_str(src: &str) -> Result<Self, IllegalSignatureTime>
Parses a serial representing a time value from a string.
In RRSIG records, the expiration and inception times are given as
serial values. Their representation format can either be the
value or a specific date in YYYYMMDDHHmmSS
format.
Trait Implementations§
source§impl CanonicalOrd<Serial> for Serial
impl CanonicalOrd<Serial> for Serial
source§fn canonical_cmp(&self, other: &Self) -> Ordering
fn canonical_cmp(&self, other: &Self) -> Ordering
self
and other
.source§fn canonical_lt(&self, other: &Rhs) -> bool
fn canonical_lt(&self, other: &Rhs) -> bool
self
is canonically less than other
.source§fn canonical_le(&self, other: &Rhs) -> bool
fn canonical_le(&self, other: &Rhs) -> bool
self
is canonically less than or equal to other
.source§fn canonical_gt(&self, other: &Rhs) -> bool
fn canonical_gt(&self, other: &Rhs) -> bool
self
is canonically greater than other
.source§fn canonical_ge(&self, other: &Rhs) -> bool
fn canonical_ge(&self, other: &Rhs) -> bool
self
is canonically greater than or equal to other
.source§impl PartialEq<Serial> for Serial
impl PartialEq<Serial> for Serial
source§impl PartialOrd<Serial> for Serial
impl PartialOrd<Serial> for Serial
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more