Skip to main content

SnapshotRng

Trait SnapshotRng 

Source
pub trait SnapshotRng: Sized {
    // Required methods
    fn capture(&self) -> Result<Vec<u8>, CheckpointError>;
    fn restore(bytes: &[u8]) -> Result<Self, CheckpointError>;
}
Expand description

An RNG whose complete internal state can be captured to bytes and restored, enabling bit-identical checkpoint resume.

Implemented for the ChaCha family (ChaCha8Rng, ChaCha12Rng, ChaCha20Rng), all of which expose fully serializable state.

Required Methods§

Source

fn capture(&self) -> Result<Vec<u8>, CheckpointError>

Serialize the full RNG state to a byte buffer.

Source

fn restore(bytes: &[u8]) -> Result<Self, CheckpointError>

Reconstruct an RNG from bytes previously produced by capture.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl SnapshotRng for ChaCha8Rng

Source§

impl SnapshotRng for ChaCha12Rng

Source§

impl SnapshotRng for ChaCha20Rng

Implementors§