Skip to documentation
SLOP

tiny.ui.Capacity

Reference tiny.ui Capacity

Defined in tiny.ui.

Capacity is the layout Capacity.derive computes from one Limits.

API (5)

Actions

Public operations.

Fields and members

Public fields and members.

No direct callersNo direct callstiny.uiCapacity
Static calls · unresolved targets: unknown · external targets: unknown.

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;
Called byCallstest sourcelib.ui.src.tree.capacitytest: derivation reports overflow rat...test sourcelib.ui.src.tree.capacitytest: derived offsets match an indepe...test sourcelib.ui.src.tree.capacitytest: the default buffer carries the ...test sourcelib.ui.src.tree.capacitytest: the owner totals two buffers, t...private sourcelib.ui.src.tree.capacityaddprivate sourcelib.ui.src.tree.capacityadd64private sourcelib.ui.src.tree.capacityalignUpprivate sourcelib.ui.src.tree.capacitymulprivate sourcelib.ui.src.tree.capacitymul64treeslotCountCapacityderive
Static calls · unresolved targets: 0 · external targets: 0.

Also reachable as

tree.Capacity.

Audit

Definitions2
Public names4
Members4
Version26.7.0
Revisiondaab053ee433