Rust library for defining and manipulating fixed-size opaque byte blobs with serialization, deserialization, hex conversion, and byte iteration capability.
// ---------------- [ File: bitcoin-blob/src/simple_rng.rs ]
crate::ix!();/// A simple pseudo-random generator to test comparisons, etc.
/// We can keep it predictable for reproducibility.
pubstructSimpleRng(u64);implSimpleRng{pubfnnew(seed:u64)->Self{Self(seed)}pubfnnext_u64(&mutself)->u64{// linear congruential generator
self.0=self.0.wrapping_mul(6364136223846793005).wrapping_add(1);self.0}/// Fill a mutable buffer with pseudo-random bytes.
pubfnfill_bytes(&mutself, buf:&mut [u8]){for chunk in buf.chunks_mut(8){let rnd =self.next_u64().to_le_bytes();let n = chunk.len();
chunk.copy_from_slice(&rnd[..n]);}}}