Skip to main content

token_bucket

Function token_bucket 

Source
pub fn token_bucket(n: u64) -> u32
Expand description

Bucket a token count into a coarse, privacy-preserving band: floor(log2(n)), with 0 and 1 both mapping to bucket 0.

Monotonic non-decreasing in n, so ordering is preserved while the exact count is not recoverable. Deterministic — the same n always yields the same bucket.