Skip to documentation
SLOP

tiny.zen.HeadingPlan

Reference tiny.zen HeadingPlan

Defined in tiny.zen.

Exact storage demand measured from one source without allocation.

API (8)

Actions

Public operations.

Fields and members

Public fields and members.

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

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;
Called byCallsNo direct callstest sourcelib.zen.src.document.plantest: heading plan counts copied text...HeadingPlanexactLimits
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.zen.src.document.plantest: heading plan accepts an exact e...test sourcelib.zen.src.document.plantest: heading plan counts copied text...private sourcelib.zen.src.document.planaddedHeadingPlanincludeHeading
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest sourcelib.zen.src.document.plantest: heading plan accepts an exact e...test sourcelib.zen.src.document.plantest: heading plan counts copied text...HeadingPlaninit
Static calls · unresolved targets: 0 · external targets: 0.

Also reachable as

document.Plan.

Audit

Definitions5
Public names10
Members4
Version26.7.0
Revisiondaab053ee433