commonlibsse_ng\re\b/
BSBitField.rs

1// Assuming BSBitFieldHeapAllocator and BSBitField are part of the RE namespace
2
3use core::{marker::PhantomData, ptr::NonNull};
4
5#[repr(C)]
6#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
7pub struct BSBitFieldHeapAllocator {
8    data: Option<NonNull<u32>>,
9}
10
11impl BSBitFieldHeapAllocator {
12    #[inline]
13    pub const fn new() -> Self {
14        Self { data: None }
15    }
16}
17
18// Buffer union equivalent in Rust
19#[repr(C)]
20pub union Buffer {
21    local: u32,
22    heap: *mut u32,
23}
24
25impl Default for Buffer {
26    #[inline]
27    fn default() -> Self {
28        Self { local: 0 }
29    }
30}
31
32impl core::fmt::Debug for Buffer {
33    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
34        unsafe {
35            f.debug_struct("Buffer").field("local", &self.local).field("heap", &self.heap).finish()
36        }
37    }
38}
39
40#[repr(C)]
41#[derive(Debug, Default)]
42pub struct BSBitField<A = BSBitFieldHeapAllocator> {
43    buffer: Buffer,
44    size: u32,
45    _phantom: PhantomData<A>,
46}
47
48impl<Allocator: Default> BSBitField<Allocator> {
49    #[inline]
50    pub const fn new() -> Self {
51        Self { buffer: Buffer { local: 0 }, size: 0, _phantom: PhantomData }
52    }
53}