Skip to main content

Serial

Struct Serial 

Source
#[repr(transparent)]
pub struct Serial(pub U32);
Available on crate feature unstable-new only.
Expand description

Serial number arithmetic.

Serial implements the “Serial number arithmetic” defined in RFC1982 with a SERIAL_BITS value of 32.

Serial should not be used interchangably or be confused with the SOA Serial Number, which is a Serial but not the sole user of “Serial number arithmetic”.

Tuple Fields§

§0: U32

Implementations§

Source§

impl Serial

Source

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

Construct a new Serial

Source

pub const fn get(&self) -> u32

Get u32 value of Serial

Source

pub fn unix_time() -> Self

Available on crate feature std only.

Measure the current time (in seconds) in serial number space.

Source§

impl Serial

Source

pub fn inc(self, num: i32) -> Self

Increment this by a non-negative number.

The number must be in the range [0, 2^31 - 1]. An i32 is used instead of a u32 because it is easier to understand and implement a non-negative check versus the upper range check.

Section 7 in RFC1982 states, in particular for the SOA Serial Number, but for any Serial number using a “SERIAL_BITS” value of 32: “The maximum defined increment is 2147483647 (2^31 - 1).”

§Panics

Panics if the number is negative.

Trait Implementations§

Source§

impl AsBytes for Serial

Source§

fn as_bytes(&self) -> &[u8]

Interpret this value as a sequence of bytes. Read more
Source§

impl BuildBytes for Serial

Source§

fn build_bytes<'bytes>( &self, bytes: &'bytes mut [u8], ) -> Result<&'bytes mut [u8], TruncationError>

Serialize into a byte sequence. Read more
Source§

fn built_bytes_size(&self) -> usize

The size of self when serialized into a byte sequence. Read more
Source§

impl Clone for Serial

Source§

fn clone(&self) -> Serial

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Serial

Source§

impl Debug for Serial

Source§

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

Formats the value using the given formatter. 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 Eq for Serial

Source§

impl From<Serial> for u32

Source§

fn from(value: Serial) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Serial

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
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<'bytes> ParseBytes<'bytes> for Serial
where U32: ParseBytes<'bytes>,

Source§

fn parse_bytes(bytes: &'bytes [u8]) -> Result<Self, ParseError>

Parse a value of Self from the given byte sequence. Read more
Source§

impl ParseBytesZC for Serial

Source§

fn parse_bytes_by_ref(bytes: &[u8]) -> Result<&Self, ParseError>

Interpret a byte sequence as an instance of Self. Read more
Source§

fn parse_bytes_in<C: ParseBytesInPlace>( container: C, ) -> Result<C::WithParsed<Self>, (C, ParseError)>

Parse bytes within the given container. Read more
Source§

impl PartialEq for Serial

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for Serial

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

The comparison of Serial Number values is defined in Section 3.2 RFC1982.

1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'bytes> SplitBytes<'bytes> for Serial
where U32: SplitBytes<'bytes>,

Source§

fn split_bytes(bytes: &'bytes [u8]) -> Result<(Self, &'bytes [u8]), ParseError>

Parse a value of Self from the start of the byte sequence. Read more
Source§

impl SplitBytesZC for Serial

Source§

fn split_bytes_by_ref(bytes: &[u8]) -> Result<(&Self, &[u8]), ParseError>

Interpret the start of a byte sequence as an instance of Self. Read more
Source§

impl StructuralPartialEq for Serial

Source§

impl UnsizedCopy for Serial

Source§

type Alignment = (<U32 as UnsizedCopy>::Alignment,)

A type with the same alignment as Self. Read more
Source§

fn ptr_with_addr(&self, addr: *const ()) -> *const Self

Change the address of a pointer to Self. Read more
Source§

fn unsized_copy_into<T: UnsizedCopyFrom<Source = Self>>(&self) -> T

Copy self into a new container. Read more
Source§

fn copy(&self) -> Self
where Self: Sized,

Copy self and return it by value. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<Source, Target> OctetsInto<Target> for Source
where Target: OctetsFrom<Source>,

Source§

type Error = <Target as OctetsFrom<Source>>::Error

Source§

fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>

Performs the conversion.
Source§

fn octets_into(self) -> Target
where Self::Error: Into<Infallible>,

Performs an infallible conversion.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

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§

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

Source§

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

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more