1use crate::sabi_types::bitarray::{bool_to_enum, enum_to_bool, BitArray64, BooleanEnum};
23////////////////////////////////////////////////////////////////////////////////
45/// Whether a field is accessible.
6#[derive(StableAbi, Debug, Copy, Clone, PartialEq, Eq)]
7#[repr(u8)]
8pub enum IsAccessible {
9///
10No = 0,
11///
12Yes = 1,
13}
1415impl IsAccessible {
16/// Constructs an IsAccessible with a bool saying whether this is accessible.
17pub const fn new(is_accessible: bool) -> Self {
18 bool_to_enum(is_accessible)
19 }
20/// Describes whether this is accessible.
21pub const fn is_accessible(self) -> bool {
22 enum_to_bool(self)
23 }
24}
2526unsafe impl BooleanEnum for IsAccessible {
27const FALSE: Self = Self::No;
28const TRUE: Self = Self::Yes;
29}
3031/// An array with whether the ith field of a prefix-type
32/// is accessible through its accessor method.
33pub type FieldAccessibility = BitArray64<IsAccessible>;
3435////////////////////////////////////////////////////////////////////////////////
3637/// Whether a field is conditional,
38/// whether it has a `#[sabi(accessible_if = expression)]` helper attribute or not.
39#[derive(StableAbi, Debug, Copy, Clone, PartialEq, Eq)]
40#[repr(u8)]
41pub enum IsConditional {
42///
43No = 0,
44///
45Yes = 1,
46}
4748impl IsConditional {
49/// Constructs an IsConditional with a bool saying this is conditional.
50pub const fn new(is_conditional: bool) -> Self {
51 bool_to_enum(is_conditional)
52 }
53/// Describes whether this is conditional.
54pub const fn is_conditional(self) -> bool {
55 enum_to_bool(self)
56 }
57}
5859unsafe impl BooleanEnum for IsConditional {
60const FALSE: Self = Self::No;
61const TRUE: Self = Self::Yes;
62}
6364/// An array with whether the ith field in the prefix of a prefix-type
65/// is conditional,which means whether it has the
66/// `#[sabi(accessible_if = expression)]` attribute applied to it.
67pub type FieldConditionality = BitArray64<IsConditional>;