Skip to main content

Module data

Module data 

Source
Expand description

DataCap — Data cap.

Two storage forms:

  • Inline — bytes in one Vec<u8>. Used for “small” Data (typically a single page).
  • Paged — page-merkleized; each page is owned by the DataCap via a reference-counted PageRef so multiple DataCap clones can share page bytes between CoW operations.

§Page-aligned invariant

DataCap content storage is always a multiple of PAGE_SIZE bytes. There is no separate logical-size field — content.len() is the size, always 4 KiB-multiple. This lets the kernel map the cap’s pages directly into a ring-3 page table without an intermediate per-call copy (see the v3 spec, §2 “Memory model”).

Callers that want to pass shorter payloads (variable-length args) pad up to the next page boundary at mint time; the meaningful bytes are interpreted by the receiver (length-prefix encoding or zero-terminator scanning).

Structs§

DataCap

Enums§

DataContent

Constants§

PAGE_SIZE
Cap-level page size. Mirrors the architecture’s 4 KiB page (must match nub_arch_x86::paging::PAGE_SIZE for direct PT mapping to work).

Functions§

alloc_page_aligned_zeroed
Allocate a zero-filled Vec<u8> of len bytes (rounded up to the next page boundary) with PAGE_SIZE-aligned backing storage.