pub enum CounterSize {
FourBit,
EightBit,
SixteenBit,
}Expand description
Bit-width of each counter.
Trades memory against overflow headroom:
| Variant | Max value | Bytes/counter | Typical use |
|---|---|---|---|
FourBit | 15 | 0.5 | Low load, k ≤ 7 |
EightBit | 255 | 1.0 | Most production loads |
SixteenBit | 65535 | 2.0 | High skew, λ > 0.8 |
Variants§
FourBit
4-bit counters (max value: 15)
- Memory: 0.5 bytes per counter
- Good for: λ < 0.3, standard distributions
- Overflow risk: <10⁻⁹ for properly sized filters
EightBit
8-bit counters (max value: 255)
- Memory: 1 byte per counter
- Good for: Most production use cases
- Overflow risk: <10⁻¹⁵ for reasonable parameters
SixteenBit
16-bit counters (max value: 65535)
- Memory: 2 bytes per counter
- Good for: High-skew distributions, λ > 0.8
- Overflow risk: Negligible for all practical workloads
Implementations§
Source§impl CounterSize
impl CounterSize
Sourcepub const fn bytes_per_counter(self) -> usize
pub const fn bytes_per_counter(self) -> usize
Get memory bytes per counter (physical storage).
Sourcepub const fn from_max_count(max: u16) -> Self
pub const fn from_max_count(max: u16) -> Self
Map a maximum counter value to the appropriate CounterSize variant.
Values 1-15 → FourBit, 16-255 → EightBit, 256+ → SixteenBit.
Trait Implementations§
Source§impl Clone for CounterSize
impl Clone for CounterSize
Source§fn clone(&self) -> CounterSize
fn clone(&self) -> CounterSize
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for CounterSize
Source§impl Debug for CounterSize
impl Debug for CounterSize
Source§impl Default for CounterSize
impl Default for CounterSize
Source§fn default() -> CounterSize
fn default() -> CounterSize
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for CounterSize
impl<'de> Deserialize<'de> for CounterSize
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for CounterSize
Source§impl Hash for CounterSize
impl Hash for CounterSize
Source§impl PartialEq for CounterSize
impl PartialEq for CounterSize
Source§fn eq(&self, other: &CounterSize) -> bool
fn eq(&self, other: &CounterSize) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for CounterSize
impl Serialize for CounterSize
impl StructuralPartialEq for CounterSize
Auto Trait Implementations§
impl Freeze for CounterSize
impl RefUnwindSafe for CounterSize
impl Send for CounterSize
impl Sync for CounterSize
impl Unpin for CounterSize
impl UnsafeUnpin for CounterSize
impl UnwindSafe for CounterSize
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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>
Converts
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>
Converts
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