sentry-types 0.48.3

Common reusable types for implementing the sentry.io protocol.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Defines the [`IndexedEnum`] trait.

/// Trait for enums that have fixed indexed variants.
pub trait IndexedEnum: private::Sealed + Sized + 'static {
    /// A slice containing all the variants in index order.
    ///
    /// The exact value is subject to change in any future release.
    const VARIANTS: &[Self];

    /// Returns this variant's unique zero-based index.
    ///
    /// The index satisfies `0 <= self.as_index() < Self::VARIANTS.len()`.
    fn as_index(&self) -> usize;
}

pub(crate) mod private {
    pub trait Sealed {}
}