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.
source§impl Serial
impl Serial
§Parsing and Composing
pub const COMPOSE_LEN: u16 = 4u16
pub fn parse<Octs: AsRef<[u8]> + ?Sized>( parser: &mut Parser<'_, Octs>, ) -> Result<Self, ParseError>
pub fn compose<Target: Composer + ?Sized>( &self, target: &mut Target, ) -> Result<(), Target::AppendError>
Trait Implementations§
source§impl CanonicalOrd for Serial
impl CanonicalOrd 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 PartialOrd for Serial
impl PartialOrd for Serial
impl Copy for Serial
impl Eq for Serial
impl StructuralPartialEq 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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)