[][src]Struct serial_int::SerialGenerator

pub struct SerialGenerator<T: Serial = u32> { /* fields omitted */ }

A utility for generating instances of a given Serial type.

See the crate documentation for more information.

Implementations

impl<T: Serial> SerialGenerator<T>[src]

pub fn new() -> Self[src]

Create a new generator.

pub fn with_init_value(value: T) -> Self[src]

Create a new generator with the given value.

Serial::START is always considered the first value. If this method is used with a greater value, SerialGenerator::previous may give an unexpected answer because the "previous" value is calculated, not recorded.

pub fn generate(&mut self) -> T[src]

Generate a new instance of the generator's Serial type.

Relies on Serial::next_increment.

pub fn previous(&self) -> Option<T>[src]

Return the previously generated value.

This method will return None if the current value is Serial::START.

The return value is calculated, not recorded. If the highest possible value has been reached, this method will continue to return one less than that value. To check that unique values can still be generated, use SerialGenerator::remaining_increments.

Relies on Serial::prev_increment.

pub fn remaining_increments(&self) -> T[src]

Return the number of unique values that can still be generated by this generator.

Relies on Serial::remaining_increments.

pub fn has_remaining_increments(&self) -> bool[src]

Return a boolean representing whether unique values can still be generated.

Relies on Serial::remaining_increments.

Trait Implementations

impl<T: Clone + Serial> Clone for SerialGenerator<T>[src]

impl<T: Debug + Serial> Debug for SerialGenerator<T>[src]

impl<T: Serial> Default for SerialGenerator<T>[src]

impl<T: Debug + Display + Serial> Display for SerialGenerator<T>[src]

impl<T: Serial> Iterator for SerialGenerator<T>[src]

type Item = T

The type of the elements being iterated over.

Auto Trait Implementations

impl<T> RefUnwindSafe for SerialGenerator<T> where
    T: RefUnwindSafe
[src]

impl<T> Send for SerialGenerator<T> where
    T: Send
[src]

impl<T> Sync for SerialGenerator<T> where
    T: Sync
[src]

impl<T> Unpin for SerialGenerator<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for SerialGenerator<T> where
    T: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.