rosu_map/section/timing_points/
effect_flags.rs1use std::{num::ParseIntError, str::FromStr};
2
3#[derive(Copy, Clone, Default, Debug, PartialEq, Eq)]
4pub struct EffectFlags(i32);
6
7impl EffectFlags {
8 pub const NONE: i32 = 0;
9 pub const KIAI: i32 = 1 << 0;
10 pub const OMIT_FIRST_BAR_LINE: i32 = 1 << 3;
11
12 pub const fn has_flag(self, flag: i32) -> bool {
14 (self.0 & flag) != 0
15 }
16}
17
18impl From<EffectFlags> for i32 {
19 fn from(kind: EffectFlags) -> Self {
20 kind.0
21 }
22}
23
24impl From<i32> for EffectFlags {
25 fn from(flags: i32) -> Self {
26 Self(flags)
27 }
28}
29
30impl FromStr for EffectFlags {
31 type Err = ParseEffectFlagsError;
32
33 fn from_str(s: &str) -> Result<Self, Self::Err> {
34 s.parse().map(Self).map_err(ParseEffectFlagsError)
35 }
36}
37
38thiserror! {
39 #[error("invalid effect flags")]
40 #[derive(Clone, Debug, PartialEq, Eq)]
42 pub struct ParseEffectFlagsError(ParseIntError);
43}