pub struct RandomSequenceBuilder<T>where
    T: QuadraticResidue,{
    pub seed_base: T,
    pub seed_offset: T,
    pub init_base: T,
    pub init_offset: T,
    pub prime: T,
    pub intermediate_xor: T,
}
Expand description

The configuration for RandomSequence, a random unique sequence generator.

These variables define the entire sequence and should not be modified with the exception of seed_base and seed_offset during initialisation.

The builder defines the internal properties of the sequence, and serialization includes all of the properties to preserve the sequence between crate versions which may change the fixed values between minor versions.

Crate versioning will bump:

  • Minor version: when the hard coded parameters are updated in favour of better ones. It is safe to serialize the RandomSequenceBuilder between minor versions.
  • Major version: when the sequence generation logic fundamentally changes the sequence, meaning it would be potentially unsafe to serialize the RandomSequenceBuilder between major crate version changes.

Fields§

§seed_base: T

The seed for the the start index.

§seed_offset: T

The seed for the offsetting addition.

§init_base: T

A value used as an xor during initialisation for start_index = f(seed_base, init_base) to deterministically pseudo-randomise it.

§init_offset: T

A value used as an xor during initialisation for offset = f(seed_offset, init_offset) to deterministically pseudo-randomise it.

§prime: T

Should be the largest prime number that fits in type T and satisfied prime = 3 mod 4.

§intermediate_xor: T

A value that provides some noise from the xor to generate a pseudo-uniform distribution.

Implementations§

source§

impl<T> RandomSequenceBuilder<T>where T: QuadraticResidue,

source

pub unsafe fn from_spec( seed_base: T, seed_offset: T, init_base: T, init_offset: T, prime: T, intermediate_xor: T ) -> Self

Initialise a config from stored settings. Not recommended unless you know what you’re doing, or these values have been taken from an already serialized RandomSequenceBuilder.

Prefer [RandomSequenceBuilderInit::new] instead.

source§

impl RandomSequenceBuilder<u8>

source

pub fn new(seed_base: u8, seed_offset: u8) -> Self

Initialise a RandomSequenceBuilder from a specific seed pair.

source§

impl RandomSequenceBuilder<u16>

source

pub fn new(seed_base: u16, seed_offset: u16) -> Self

Initialise a RandomSequenceBuilder from a specific seed pair.

source§

impl RandomSequenceBuilder<u32>

source

pub fn new(seed_base: u32, seed_offset: u32) -> Self

Initialise a RandomSequenceBuilder from a specific seed pair.

source§

impl RandomSequenceBuilder<u64>

source

pub fn new(seed_base: u64, seed_offset: u64) -> Self

Initialise a RandomSequenceBuilder from a specific seed pair.

source§

impl RandomSequenceBuilder<usize>

source

pub fn new(seed_base: usize, seed_offset: usize) -> Self

Initialise a RandomSequenceBuilder from a specific seed pair.

source§

impl RandomSequenceBuilder<u8>

source

pub fn rand(rng: &mut impl RngCore) -> Self

Initialise a RandomSequenceBuilder from a random seed.

source§

impl RandomSequenceBuilder<u16>

source

pub fn rand(rng: &mut impl RngCore) -> Self

Initialise a RandomSequenceBuilder from a random seed.

source§

impl RandomSequenceBuilder<u32>

source

pub fn rand(rng: &mut impl RngCore) -> Self

Initialise a RandomSequenceBuilder from a random seed.

source§

impl RandomSequenceBuilder<u64>

source

pub fn rand(rng: &mut impl RngCore) -> Self

Initialise a RandomSequenceBuilder from a random seed.

source§

impl RandomSequenceBuilder<usize>

source

pub fn rand(rng: &mut impl RngCore) -> Self

Initialise a RandomSequenceBuilder from a random seed.

Trait Implementations§

source§

impl<T> Clone for RandomSequenceBuilder<T>where T: QuadraticResidue + Clone,

source§

fn clone(&self) -> RandomSequenceBuilder<T>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T> Debug for RandomSequenceBuilder<T>where T: QuadraticResidue + Debug,

source§

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

Formats the value using the given formatter. Read more
source§

impl<'de, T> Deserialize<'de> for RandomSequenceBuilder<T>where T: QuadraticResidue + Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T> From<RandomSequenceBuilder<T>> for RandomSequence<T>where T: QuadraticResidue, RandomSequence<T>: Iterator<Item = T>,

source§

fn from(value: RandomSequenceBuilder<T>) -> Self

Converts to this type from the input type.
source§

impl<T> IntoIterator for RandomSequenceBuilder<T>where T: QuadraticResidue, RandomSequence<T>: Iterator<Item = T>,

source§

fn into_iter(self) -> Self::IntoIter

Build a RandomSequence iterator from this config.

§

type Item = T

The type of the elements being iterated over.
§

type IntoIter = RandomSequence<T>

Which kind of iterator are we turning this into?
source§

impl<T> PartialEq for RandomSequenceBuilder<T>where T: QuadraticResidue + PartialEq,

source§

fn eq(&self, other: &RandomSequenceBuilder<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

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

impl<T> Serialize for RandomSequenceBuilder<T>where T: QuadraticResidue + Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T> Copy for RandomSequenceBuilder<T>where T: QuadraticResidue + Copy,

source§

impl<T> Eq for RandomSequenceBuilder<T>where T: QuadraticResidue + Eq,

source§

impl<T> StructuralEq for RandomSequenceBuilder<T>where T: QuadraticResidue,

source§

impl<T> StructuralPartialEq for RandomSequenceBuilder<T>where T: QuadraticResidue,

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for RandomSequenceBuilder<T>where T: RefUnwindSafe,

§

impl<T> Send for RandomSequenceBuilder<T>where T: Send,

§

impl<T> Sync for RandomSequenceBuilder<T>where T: Sync,

§

impl<T> Unpin for RandomSequenceBuilder<T>where T: Unpin,

§

impl<T> UnwindSafe for RandomSequenceBuilder<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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<T> ToOwned for Twhere T: Clone,

§

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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,