tiny.zen.HeadingPlan
Defined in tiny.zen.
Exact storage demand measured from one source without allocation.
API (8)
Actions
Public operations.
exactLimits: Returns the smallest limits that admit this plan.includeHeadinginitrequire: Rejects when any measured region exceeds supplied limits.
Fields and members
Public fields and members.
Source
Source: lib/zen/src/document/plan.zig:22
zig
/// Exact storage demand measured from one source without allocation.pub const Plan = struct { /// Total bytes in the inspected Markdown source. source_bytes: usize, /// Number of heading descriptors required. headings: usize = 0, /// Total visible heading-text bytes copied into storage. text_bytes: usize = 0, /// Total resolved heading-ID bytes copied into storage. id_bytes: usize = 0, pub fn init(source_bytes: usize) Plan { return .{ .source_bytes = source_bytes }; } pub fn includeHeading( self: *Plan, text: []const u8, id_bytes: usize, ) error{CapacityOverflow}!void { const headings = try added(self.headings, 1); const text_bytes = try added(self.text_bytes, text.len); const total_id_bytes = try added(self.id_bytes, id_bytes); self.headings = headings; self.text_bytes = text_bytes; self.id_bytes = total_id_bytes; } /// Returns the smallest limits that admit this plan. pub fn exactLimits(self: Plan) Limits { return .{ .max_headings = self.headings, .max_text_bytes = self.text_bytes, .max_id_bytes = self.id_bytes, }; } /// Rejects when any measured region exceeds supplied limits. pub fn require(self: Plan, limits: Limits) model.Exhaustion!void { if (self.headings > limits.max_headings) return error.HeadingCapacityExceeded; if (self.text_bytes > limits.max_text_bytes) { return error.HeadingTextByteCapacityExceeded; } if (self.id_bytes > limits.max_id_bytes) { return error.HeadingIdByteCapacityExceeded; } }};Source: lib/zen/src/root.zig:186
zig
/// Exact heading storage demand measured without allocation.pub const HeadingPlan = document.Plan;Also reachable as
Audit
| Definitions | 5 |
|---|---|
| Public names | 10 |
| Members | 4 |
| Version | 26.7.0 |
| Revision | daab053ee433 |