pub struct SeedSequence { /* private fields */ }Expand description
SeedSequence — deterministic entropy expansion and child spawning.
Equivalent to numpy.random.SeedSequence. Construct from an
entropy: u64; call generate_state for
n_words 32-bit seed words, or spawn to create
n independent child sequences whose state is reproducibly derived
from this one.
Implementations§
Source§impl SeedSequence
impl SeedSequence
Sourcepub fn with_spawn_key(entropy: u64, spawn_key: Vec<u64>) -> Self
pub fn with_spawn_key(entropy: u64, spawn_key: Vec<u64>) -> Self
Sourcepub fn generate_state(&self, n_words: usize) -> Vec<u32>
pub fn generate_state(&self, n_words: usize) -> Vec<u32>
Generate n_words 32-bit seed words from this sequence.
The output is a deterministic function of (entropy, spawn_key)
only — calling generate_state repeatedly returns the same
words. Different sequences produce statistically independent
outputs.
Sourcepub fn generate_u64(&self) -> u64
pub fn generate_u64(&self) -> u64
Generate a single u64 derived from this sequence — convenient for
seeding a BitGenerator via BitGenerator::seed_from_u64.
Sourcepub fn seed<B: BitGenerator>(&self) -> B
pub fn seed<B: BitGenerator>(&self) -> B
Seed a fresh BitGenerator deterministically from this sequence.
Sourcepub fn spawn(&mut self, n: usize) -> Vec<SeedSequence>
pub fn spawn(&mut self, n: usize) -> Vec<SeedSequence>
Create n independent child sequences.
Each child has the same entropy as the parent but a different
spawn_key, so their generate_state outputs do not overlap.
Mutates self’s spawn counter so successive calls yield fresh
children.
Trait Implementations§
Source§impl Clone for SeedSequence
impl Clone for SeedSequence
Source§fn clone(&self) -> SeedSequence
fn clone(&self) -> SeedSequence
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SeedSequence
impl RefUnwindSafe for SeedSequence
impl Send for SeedSequence
impl Sync for SeedSequence
impl Unpin for SeedSequence
impl UnsafeUnpin for SeedSequence
impl UnwindSafe for SeedSequence
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§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more