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 addition and comparison. 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
impl Serial
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
.
Sourcepub fn scan_rrsig<C: CharSource>(
scanner: &mut Scanner<C>,
) -> Result<Self, ScanError>
pub fn scan_rrsig<C: CharSource>( scanner: &mut Scanner<C>, ) -> Result<Self, ScanError>
Scan a serial represention signature time values.
In RRSIG records, the expiration and inception time is given as
serial values. Their master file format can either be the signature
value or a specific date in YYYYMMDDHHmmSS
format.