nativeview_store/node/
row.rs1use crate::id::{NodeId, TableSet};
5use crate::span_pool::ChildSpan;
6use crate::table::TableSlot;
7
8pub const LIVE: u8 = 1 << 0;
10pub const INLINE: u8 = 1 << 1;
12pub(crate) const CHILDREN_DIRTY: u8 = 1 << 2;
14pub const CONNECTED: u8 = 1 << 3;
17pub(crate) const DEAD_MASK: u8 = 0b11 << 3;
19pub(crate) const DEAD_PENDING_FREE: u8 = 1 << 3;
21pub(crate) const DEAD_IN_FREE: u8 = 2 << 3;
23pub(crate) const DEAD_RETIRED: u8 = 3 << 3;
25pub(crate) const CREATED: u8 = 1 << 5;
27pub(crate) const CHILD_SEEN: u8 = 1 << 6;
29pub(crate) const ANCESTOR_MARK: u8 = 1 << 7;
31
32const _: () = {
33 assert!(LIVE == nativeview_abi::NV_NODE_ROW_FLAG_LIVE);
34 assert!(INLINE == nativeview_abi::NV_NODE_ROW_FLAG_INLINE);
35 assert!((LIVE & INLINE) == 0);
36 assert!(
37 ((LIVE | INLINE) & (CHILDREN_DIRTY | CONNECTED | DEAD_MASK | CREATED | CHILD_SEEN | ANCESTOR_MARK))
38 == 0
39 );
40 assert!((CHILDREN_DIRTY & (CONNECTED | DEAD_MASK | CREATED | CHILD_SEEN | ANCESTOR_MARK)) == 0);
41 assert!((CONNECTED & (CREATED | CHILD_SEEN | ANCESTOR_MARK)) == 0);
42 assert!((DEAD_MASK & (CREATED | CHILD_SEEN | ANCESTOR_MARK)) == 0);
43 assert!((CREATED & (CHILD_SEEN | ANCESTOR_MARK)) == 0);
44 assert!((CHILD_SEEN & ANCESTOR_MARK) == 0);
45};
46
47#[repr(C, align(32))]
49#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
50pub struct NodeRow {
51 pub tables: TableSet,
53 pub parent: NodeId,
55 pub children: ChildSpan,
57 pub generation: u8,
58 pub primary_slot: TableSlot,
61 pub effects: u8,
63 pub(crate) flags: u8,
64}
65
66impl NodeRow {
67 #[inline(always)]
68 pub const fn is_live(&self) -> bool {
69 (self.flags & LIVE) != 0
70 }
71
72 #[inline(always)]
73 pub const fn is_inline(&self) -> bool {
74 (self.flags & INLINE) != 0
75 }
76
77 #[inline(always)]
78 pub const fn is_connected(&self) -> bool {
79 (self.flags & (LIVE | CONNECTED)) == (LIVE | CONNECTED)
80 }
81}
82
83const _: () = {
87 use core::mem::{align_of, offset_of, size_of};
88 use nativeview_abi::NvNodeRow;
89 assert!(cfg!(target_endian = "little"));
90 assert!(size_of::<NodeRow>() == 32);
91 assert!(align_of::<NodeRow>() == 32);
92 assert!(size_of::<NodeRow>() == size_of::<NvNodeRow>());
93 assert!(align_of::<NodeRow>() >= align_of::<NvNodeRow>());
94 assert!(size_of::<TableSet>() == size_of::<[u32; 4]>());
95 assert!(offset_of!(NodeRow, tables) == offset_of!(NvNodeRow, table_set));
96 assert!(offset_of!(NodeRow, parent) == offset_of!(NvNodeRow, parent));
97 assert!(
98 offset_of!(NodeRow, children) + offset_of!(ChildSpan, off)
99 == offset_of!(NvNodeRow, child_off)
100 );
101 assert!(
102 offset_of!(NodeRow, children) + offset_of!(ChildSpan, len)
103 == offset_of!(NvNodeRow, child_len)
104 );
105 assert!(offset_of!(NodeRow, generation) == offset_of!(NvNodeRow, generation));
106 assert!(offset_of!(NodeRow, primary_slot) == offset_of!(NvNodeRow, primary_slot));
107 assert!(offset_of!(NodeRow, effects) == offset_of!(NvNodeRow, effects));
108 assert!(offset_of!(NodeRow, flags) == offset_of!(NvNodeRow, flags));
109 assert!(LIVE == nativeview_abi::NV_NODE_ROW_FLAG_LIVE);
110 assert!(INLINE == nativeview_abi::NV_NODE_ROW_FLAG_INLINE);
111};