tiny.acp.ReaderCapacity
Defined in tiny.acp.
A caller learns the buffer size before any buffer exists, for example to set aside the reader's share of one larger region of memory.
API (3)
Actions
Public operations.
derive: A caller works out the buffer size for a line limit and learns early when the limit is too large.
Fields and members
Public fields and members.
Source
Source: lib/acp/src/reader/capacity.zig:19
zig
/// A caller learns the buffer size before any buffer exists, for example to set aside the reader's/// share of one larger region of memory. The structure holds the line limit and the buffer size it/// needs. `derive` builds it. Another program in the repository adds the buffer size into the size/// of one region it allocates up front. The package exports it as `acp.ReaderCapacity`.pub const Capacity = struct { /// The line limit, copied from `Limits`. message_bytes: usize, /// The buffer size: the line limit plus one byte, for the newline after a longest line. The /// value is always above the line limit and above zero. storage_bytes: usize, /// A caller works out the buffer size for a line limit and learns early when the limit is too /// large. The function returns the line limit with its buffer size. The call fails with /// `error.CapacityOverflow` when the limit plus one does not fit in a `usize`. The call /// allocates nothing. pub fn derive(limits: Limits) DeriveError!Capacity { const storage_bytes = std.math.add(usize, limits.message_bytes, 1) catch return error.CapacityOverflow; std.debug.assert(storage_bytes > limits.message_bytes); std.debug.assert(storage_bytes != 0); return .{ .message_bytes = limits.message_bytes, .storage_bytes = storage_bytes, }; }};Source: lib/acp/src/root.zig:86
zig
pub const ReaderCapacity = reader.Capacity;Also reachable as
Audit
| Definitions | 2 |
|---|---|
| Public names | 4 |
| Members | 2 |
| Version | 26.7.0 |
| Revision | daab053ee433 |