tiny.content.Capacity
Defined in tiny.content.
The sizes and the work counts a store was built with, carried by a caller from derivation into the store it builds and re-read by every capability to admit a reference.
API (9)
Actions
Public operations.
derive: Turns caller limits into the byte counts and work counts of a store, called once before a caller lays out storage so it learns how many bytes the store needs and how much work its operations can cost.validateReference: Checks one reference against the store's per-object byte limit, called first by both capabilities so a reference that is too large for the store never reaches the provider.
Types and contracts
Public types and contracts.
Fields and members
Public fields and members.
Source
Source: lib/content/src/model.zig:147
zig
/// The sizes and the work counts a store was built with, carried by a caller/// from derivation into the store it builds and re-read by every capability to/// admit a reference. The struct holds the limits it came from, the retained/// metadata and storage byte counts, and a worst-case work count for a read, a/// publication, and teardown.pub const Capacity = struct { limits: Limits, metadata_bytes: u64, storage_bytes: u64, read_work: u64, publication_work: u64, teardown_work: u64, pub const DeriveError: type = CapacityError; /// Turns caller limits into the byte counts and work counts of a store, /// called once before a caller lays out storage so it learns how many bytes /// the store needs and how much work its operations can cost. The /// calculation returns `ObjectLimitEmpty` for a store of no objects, /// `TotalByteLimitTooSmall` when the total is below one object, /// `TotalByteLimitExceeded` when the total is above the object count times /// the bytes per object, and `CapacityArithmeticOverflow` when any of the /// products or sums does not fit a `u64`. The function sizes retained /// storage as one metadata entry per object, plus the total content bytes, /// plus one more object for the staging region. Work counts bound one read /// at the object count plus twice the bytes of one object, one publication /// at the object count plus six times the bytes of one object, which covers /// four hashing passes and two copies, and teardown at one step per object. pub fn derive(limits: Limits) DeriveError!Capacity { if (limits.objects == 0) return error.ObjectLimitEmpty; if (limits.total_bytes < limits.object_bytes) { return error.TotalByteLimitTooSmall; } const possible_total = multiplied(limits.objects, limits.object_bytes); if (possible_total < limits.total_bytes) { return error.TotalByteLimitExceeded; } const metadata_bytes = try multipliedChecked( limits.objects, @sizeOf(Metadata), ); const staged_storage = try added(metadata_bytes, limits.total_bytes); const storage_bytes = try added(staged_storage, limits.object_bytes); const read_bytes = try multipliedChecked(limits.object_bytes, 2); const read_work = try added(limits.objects, read_bytes); const publication_hash_passes: u8 = 4; const publication_copy_passes: u8 = 2; const publication_byte_passes = publication_hash_passes + publication_copy_passes; const publication_bytes = try multipliedChecked( limits.object_bytes, publication_byte_passes, ); const publication_work = try added(limits.objects, publication_bytes); return .{ .limits = limits, .metadata_bytes = metadata_bytes, .storage_bytes = storage_bytes, .read_work = read_work, .publication_work = publication_work, .teardown_work = limits.objects, }; } /// Checks one reference against the store's per-object byte limit, called /// first by both capabilities so a reference that is too large for the /// store never reaches the provider. The check returns /// `ContentExtentExceeded` when the reference's extent is above that limit. pub fn validateReference( self: Capacity, reference: Reference, ) ReferenceError!void { if (reference.extent.bytes > self.limits.object_bytes) { return error.ContentExtentExceeded; } }};Source: lib/content/src/root.zig:27
zig
pub const Capacity = model.Capacity;Audit
| Definitions | 4 |
|---|---|
| Public names | 4 |
| Members | 6 |
| Version | 26.7.0 |
| Revision | daab053ee433 |