tiny.syn.SpanCapacity
Defined in span.capacity.
The sizes that follow from one Limits value, computed without allocating.
API (5)
Actions
Public operations.
derive: Returns the sizes forlimits.
Fields and members
Public fields and members.
Source
Source: lib/syn/src/span/capacity.zig:39
zig
/// The sizes that follow from one `Limits` value, computed without allocating. A caller derives it/// before allocating, to learn the exact bytes span storage will take, and the storage keeps its/// own copy.pub const Capacity = struct { /// The limits the sizes were derived from, as given. limits: Limits, /// The span capacity: how many spans the storage holds, equal to `limits.max_text_bytes`. A /// line within the limit never needs more, because each kept span covers at least one byte and /// no two overlap. span_capacity: usize, /// The bytes those spans take: `span_capacity` times the size of one `Span`. span_bytes: usize, /// The bytes `Storage.init` allocates, in one region, equal to `span_bytes`. `Storage.status` /// reports the same number, and the README example checks that the two agree. The byte count is /// zero when the limit is zero, and then `Storage.init` allocates nothing. storage_bytes: usize, /// Returns the sizes for `limits`. A caller computes the storage size ahead of time, for /// example to check a memory budget, and `Storage.init` calls it too. `Capacity.derive` fails /// with `error.CapacityOverflow` when `max_text_bytes` times the size of one `Span` overflows a /// `usize`. The call allocates nothing and reads nothing but its argument. pub fn derive(limits: Limits) DeriveError!Capacity { const span_bytes = std.math.mul( usize, limits.max_text_bytes, @sizeOf(model.Span), ) catch return error.CapacityOverflow; return .{ .limits = limits, .span_capacity = limits.max_text_bytes, .span_bytes = span_bytes, .storage_bytes = span_bytes, }; }};Source: lib/syn/src/root.zig:47
zig
pub const SpanCapacity = span.Capacity;Also reachable as
Audit
| Definitions | 2 |
|---|---|
| Public names | 6 |
| Members | 4 |
| Version | 26.7.0 |
| Revision | daab053ee433 |