sentry_types/indexed_enum.rs
1//! Defines the [`IndexedEnum`] trait.
2
3/// Trait for enums that have fixed indexed variants.
4pub trait IndexedEnum: private::Sealed + Sized + 'static {
5 /// A slice containing all the variants in index order.
6 ///
7 /// The exact value is subject to change in any future release.
8 const VARIANTS: &[Self];
9
10 /// Returns this variant's unique zero-based index.
11 ///
12 /// The index satisfies `0 <= self.as_index() < Self::VARIANTS.len()`.
13 fn as_index(&self) -> usize;
14}
15
16pub(crate) mod private {
17 pub trait Sealed {}
18}