pub struct SparseIdGenerator { /* private fields */ }Expand description
Sparse ID Generator for Managed Space
Generates cryptographically sparse IDs to prevent enumeration attacks. Uses a cryptographically secure pseudo-random number generator with a sparse distribution algorithm.
Implementations§
Source§impl SparseIdGenerator
impl SparseIdGenerator
Sourcepub fn new(seed: Option<u64>) -> Self
pub fn new(seed: Option<u64>) -> Self
Create a new sparse ID generator
§Arguments
seed- Optional seed for the CSPRNG (defaults to current time)
Sourcepub fn generate_sparse_id(&mut self) -> u32
pub fn generate_sparse_id(&mut self) -> u32
Generate a sparse ID in Managed Space
This function creates IDs that are:
- Within Managed Space range (0x00000000 to 0x7FFFFFFF)
- Cryptographically sparse to prevent enumeration
- Unique within the generator instance
§Returns
A 32-bit ID suitable for Managed Space
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SparseIdGenerator
impl RefUnwindSafe for SparseIdGenerator
impl Send for SparseIdGenerator
impl Sync for SparseIdGenerator
impl Unpin for SparseIdGenerator
impl UnsafeUnpin for SparseIdGenerator
impl UnwindSafe for SparseIdGenerator
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
Mutably borrows from an owned value. Read more