casper_executor_wasm_common/
flags.rs1use bitflags::bitflags;
3
4bitflags! {
5 #[repr(transparent)]
7 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
8 pub struct ReturnFlags: u32 {
9 const REVERT = 0x0000_0001;
11
12 const _ = !0;
14 }
15
16 #[repr(transparent)]
17 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
18 pub struct EntryPointFlags: u32 {
19 const CONSTRUCTOR = 0x0000_0001;
20 const FALLBACK = 0x0000_0002;
21 }
22
23 #[repr(transparent)]
25 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
26 pub struct CallFlags: u32 {
27 }
29}
30
31impl Default for EntryPointFlags {
32 fn default() -> Self {
33 Self::empty()
34 }
35}
36
37impl Default for CallFlags {
38 fn default() -> Self {
39 Self::empty()
40 }
41}
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46
47 #[test]
48 fn test_return_flags() {
49 assert_eq!(ReturnFlags::empty().bits(), 0x0000_0000);
50 assert_eq!(ReturnFlags::REVERT.bits(), 0x0000_0001);
51 }
52
53 #[test]
54 fn creating_from_invalid_bit_flags_does_not_fail() {
55 let _return_flags = ReturnFlags::from_bits(u32::MAX).unwrap();
56 let _revert = ReturnFlags::from_bits(0x0000_0001).unwrap();
57 let _empty = ReturnFlags::from_bits(0x0000_0000).unwrap();
58 }
59}