pub struct Serial(pub u32);
Expand description

A serial number.

Serial numbers are regular integers with a special notion for comparison in order to be able to deal with roll-over.

Specifically, addition and comparison are defined in RFC 1982. 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

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.