1use std::{
2 fmt::Debug,
3 ops::{BitAnd, BitOr, BitXor},
4};
5
6macro_rules! wrap_bit_ops {
7 ($bitstruct:tt) => {
8 impl BitAnd for $bitstruct {
9 type Output = Self;
10 fn bitand(self, rhs: Self) -> Self::Output {
11 Self(self.0 & rhs.0)
12 }
13 }
14
15 impl BitOr for $bitstruct {
16 type Output = Self;
17 fn bitor(self, rhs: Self) -> Self::Output {
18 Self(self.0 | rhs.0)
19 }
20 }
21
22 impl BitXor for $bitstruct {
23 type Output = Self;
24 fn bitxor(self, rhs: Self) -> Self::Output {
25 Self(self.0 ^ rhs.0)
26 }
27 }
28
29 impl PartialEq for $bitstruct {
30 fn eq(&self, other: &Self) -> bool {
31 self.0 == other.0
32 }
33 }
34
35 impl Eq for $bitstruct {}
36
37 impl Debug for $bitstruct {
38 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
39 f.write_str(format!("{:b}", self.0).as_str())
40 }
41 }
42
43 impl $bitstruct {
44 pub fn is_none(&self) -> bool {
46 self.0 == 0
47 }
48
49 pub fn null() -> Self {
51 Self(0)
52 }
53 }
54 };
55}
56
57#[repr(transparent)]
59#[derive(Clone, Copy)]
60pub struct BufferFlags(u8);
61wrap_bit_ops!(BufferFlags);
62
63impl BufferFlags {
64 pub const UNIFORM: Self = Self(0b001);
66 pub const TRANSFER: Self = Self(0b010);
69 pub const SYNCED: Self = Self(0b100);
71}