use bitflags::bitflags;
bitflags! {
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ReturnFlags: u32 {
const REVERT = 0x0000_0001;
const _ = !0;
}
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct EntryPointFlags: u32 {
const CONSTRUCTOR = 0x0000_0001;
const FALLBACK = 0x0000_0002;
}
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct CallFlags: u32 {
}
}
impl Default for EntryPointFlags {
fn default() -> Self {
Self::empty()
}
}
impl Default for CallFlags {
fn default() -> Self {
Self::empty()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_return_flags() {
assert_eq!(ReturnFlags::empty().bits(), 0x0000_0000);
assert_eq!(ReturnFlags::REVERT.bits(), 0x0000_0001);
}
#[test]
fn creating_from_invalid_bit_flags_does_not_fail() {
let _return_flags = ReturnFlags::from_bits(u32::MAX).unwrap();
let _revert = ReturnFlags::from_bits(0x0000_0001).unwrap();
let _empty = ReturnFlags::from_bits(0x0000_0000).unwrap();
}
}