pub struct NodePages<'a> { /* private fields */ }Expand description
Page-based flat node array using Cell<Node> for interior mutability.
Nodes are allocated sequentially and addressed by flat u32 indices.
Pages of PAGE_SIZE nodes each are arena-allocated on demand.
Cell<Node> allows mutation through a shared reference, which is
needed when the builder holds &mut to its own state but only &
to the pages for sibling/parent fixup.
Implementations§
Source§impl<'a> NodePages<'a>
impl<'a> NodePages<'a>
Sourcepub fn alloc(&mut self) -> Result<u32, BufferDocumentError>
pub fn alloc(&mut self) -> Result<u32, BufferDocumentError>
Allocates the next node slot and returns its flat index.
A new page is allocated when the current page is full.
§Errors
Returns BufferDocumentError::Overflow if the index would exceed u32::MAX - 1.
Sourcepub fn set(&self, node_ref: u32, node: Node)
pub fn set(&self, node_ref: u32, node: Node)
Writes a node at the given flat index (interior mutability via Cell).
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for NodePages<'a>
impl<'a> !Send for NodePages<'a>
impl<'a> !Sync for NodePages<'a>
impl<'a> !UnwindSafe for NodePages<'a>
impl<'a> Freeze for NodePages<'a>
impl<'a> Unpin for NodePages<'a>
impl<'a> UnsafeUnpin for NodePages<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more