#[non_exhaustive]#[repr(i32)]pub enum Cardinality {
Unspecified = 0,
Low = 1,
Medium = 2,
High = 3,
Unbounded = 4,
}Expand description
Bound on the number of distinct values a field admits at runtime.
Drives lint L001 (LABEL fields must be Low or Medium) and L005 (enum variant count must fit the cap). See 10-data-model.md § 4.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Unspecified = 0
Never appears in a well-formed schema.
Low = 1
< 10 distinct values (status, boolean).
Medium = 2
< 10_000 distinct values (route, tenant).
High = 3
< 1_000_000 distinct values (user_id) — illegal for LABEL.
Unbounded = 4
Open / unbounded — illegal for LABEL and MEASUREMENT.
Implementations§
Source§impl Cardinality
impl Cardinality
Sourcepub const fn cap(self) -> u64
pub const fn cap(self) -> u64
Numeric cap: the maximum distinct value count permitted at this level.
Returns u64::MAX for Unbounded. Used by lint L005 (variant count).
Unspecified returns 0 — a schema that did not declare cardinality
should fail the cap check.
Sourcepub const fn is_label_compatible(self) -> bool
pub const fn is_label_compatible(self) -> bool
True if this cardinality is permitted on a FieldKind::Label field.
Labels become metric/span dimensions; only Low and Medium are safe.
Sourcepub const fn is_measurement_compatible(self) -> bool
pub const fn is_measurement_compatible(self) -> bool
True if this cardinality is permitted on a FieldKind::Measurement
field. Unbounded is illegal — measurement values come from the
numeric type, not from the cardinality.
Trait Implementations§
Source§impl Clone for Cardinality
impl Clone for Cardinality
Source§fn clone(&self) -> Cardinality
fn clone(&self) -> Cardinality
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Cardinality
impl Debug for Cardinality
Source§impl Default for Cardinality
impl Default for Cardinality
Source§fn default() -> Cardinality
fn default() -> Cardinality
Source§impl<'de> Deserialize<'de> for Cardinality
impl<'de> Deserialize<'de> for Cardinality
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>,
Source§impl Enumeration for Cardinality
impl Enumeration for Cardinality
Source§fn proto_name(&self) -> &'static str
fn proto_name(&self) -> &'static str
.proto file.Source§impl FromStr for Cardinality
impl FromStr for Cardinality
Source§impl Hash for Cardinality
impl Hash for Cardinality
Source§impl PartialEq for Cardinality
impl PartialEq for Cardinality
Source§fn eq(&self, other: &Cardinality) -> bool
fn eq(&self, other: &Cardinality) -> bool
self and other values to be equal, and is used by ==.