orx_concurrent_option/
states.rs1use core::sync::atomic::Ordering;
2
3pub type StateU8 = u8;
5
6pub const ORDER_LOAD: Ordering = Ordering::Acquire;
7pub const ORDER_STORE: Ordering = Ordering::SeqCst;
8
9pub const NONE: StateU8 = 0;
11pub const RESERVED: StateU8 = 1;
13pub const SOME: StateU8 = 2;
15
16#[derive(Debug, Clone, Copy, PartialEq, Eq)]
18pub enum State {
19 None,
21 Some,
23 Reserved,
25}
26
27impl State {
28 #[allow(clippy::panic, clippy::missing_panics_doc)]
29 pub(crate) fn new(state: StateU8) -> Self {
30 match state {
31 NONE => Self::None,
32 SOME => Self::Some,
33 RESERVED => Self::Reserved,
34 _ => panic!("should be either of the three valid states"),
35 }
36 }
37}