tiny.ui.Capacity
Defined in tiny.ui.
Capacity is the layout Capacity.derive computes from one Limits.
API (5)
Actions
Public operations.
derive:Capacity.deriveplaces the ten tables after the 152 byte header, each at its element alignment, and rounds the block up to 8 bytes.
Fields and members
Public fields and members.
Source
Source: lib/ui/src/tree/capacity.zig:76
zig
/// `Capacity` is the layout `Capacity.derive` computes from one `Limits`./// `Capacity.offsets` holds the byte offset of each table in a block, in `arrays` order./// `Capacity.buffer_bytes` is the size of one block, and `admit` rejects a longer publish/// buffer with `error.PublishTooLarge`. `Capacity.total_bytes` is the size of the one/// allocation a `Store` makes.pub const Capacity = struct { limits: Limits = .{}, offsets: [array_count]u32 = @splat(0), buffer_bytes: u32 = 0, total_bytes: u64 = 0, /// `Capacity.derive` places the ten tables after the 152 byte header, each at its element /// alignment, and rounds the block up to 8 bytes. The total is two blocks, two identity /// maps of `map_slots` words, two word arrays of `nodes` entries, one of `atoms` entries, /// and one of `texts` entries. It returns `error.CapacityOverflow` when a size overflows /// or when `map_slots` is below `slotCount(nodes)`. pub fn derive(limits: Limits) Error!Capacity { var out = Capacity{ .limits = limits }; var cursor: u32 = abi.header_bytes; inline for (arrays, 0..) |entry, index| { cursor = try alignUp(cursor, entry.alignment); out.offsets[index] = cursor; cursor = try add(cursor, try mul(@field(limits, entry.limit), entry.bytes)); } out.buffer_bytes = try alignUp(cursor, block_alignment); if (limits.map_slots < slotCount(limits.nodes)) return error.CapacityOverflow; const buffers = try mul64(out.buffer_bytes, 2); const maps = try mul64(try mul(limits.map_slots, 4), 2); const dirty = try mul(limits.nodes, 4); const place = try mul(limits.nodes, 4); const atom_remap = try mul(limits.atoms, 4); const text_remap = try mul(limits.texts, 4); var total = try add64(buffers, maps); total = try add64(total, dirty); total = try add64(total, place); total = try add64(total, atom_remap); out.total_bytes = try add64(total, text_remap); return out; }};Source: lib/ui/src/root.zig:31
zig
pub const Capacity = tree.Capacity;Also reachable as
Audit
| Definitions | 2 |
|---|---|
| Public names | 4 |
| Members | 4 |
| Version | 26.7.0 |
| Revision | daab053ee433 |