paft_domain/
market_state.rs1use std::str::FromStr;
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
5#[non_exhaustive]
6pub enum MarketState {
7 Pre,
9 Regular,
11 Post,
13 #[default]
15 Closed,
16 Halted,
18 Suspended,
20 Auction,
22}
23
24crate::string_enum_closed_with_code!(
25 MarketState,
26 "MarketState",
27 {
28 "PREMARKET" => MarketState::Pre,
29 "REGULAR" => MarketState::Regular,
30 "POSTMARKET" => MarketState::Post,
31 "CLOSED" => MarketState::Closed,
32 "HALTED" => MarketState::Halted,
33 "SUSPENDED" => MarketState::Suspended,
34 "AUCTION" => MarketState::Auction
35 },
36 {
37 "PRE" => MarketState::Pre,
38 "POST" => MarketState::Post,
39 "PRE_MARKET" => MarketState::Pre,
40 "POST_MARKET" => MarketState::Post,
41 }
42);
43
44crate::impl_display_via_code!(MarketState);
45
46impl MarketState {
47 #[must_use]
49 pub const fn full_name(&self) -> &'static str {
50 match self {
51 Self::Pre => "Pre-market",
52 Self::Regular => "Regular session",
53 Self::Post => "Post-market",
54 Self::Closed => "Closed",
55 Self::Halted => "Halted",
56 Self::Suspended => "Suspended",
57 Self::Auction => "Auction",
58 }
59 }
60
61 #[must_use]
63 pub const fn is_trading(&self) -> bool {
64 matches!(self, Self::Pre | Self::Regular | Self::Post)
65 }
66}