Skip to documentation
SLOP

tiny.png.EncodeStorage

Reference tiny.png EncodeStorage

Defined in tiny.png.

API (20)

Actions

Public operations.

Types and contracts

Public types and contracts.

Fields and members

Public fields and members.

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

Source

Source: lib/png/src/encode/storage.zig:24

zig
pub const Storage = struct {    phase: alloc_phase.capacity.Phase,    capacity: capacity_mod.Capacity,    bytes: []align(capacity_mod.storage_alignment) u8,    window: []u8,    raw: []u8,    count: []u8,    output: []u8,    in_use: bool = false,    pub const Limits: type = capacity_mod.Limits;    pub const Capacity: type = capacity_mod.Capacity;    pub const Exhaustion: type = model.Exhaustion;    pub const InitError = std.mem.Allocator.Error || capacity_mod.DeriveError;    pub const AcquireError: type = plan_mod.Error;    pub const claim: alloc_phase.capacity.Declaration = .{        .source = .{            .id = "png.encode_storage",            .kind = .phase_static,            .limit_source = .caller,            .storage = .{                .covered = &.{                    .{                        .id = "exact_png_encoding_plan",                        .lifetime = .steady,                        .detail = "exact PNG encoding plan",                    },                    .{                        .id = "deflate_window_and_streaming_scratch",                        .lifetime = .steady,                        .detail = "DEFLATE window and streaming scratch",                    },                    .{                        .id = "encoded_png_output_bytes",                        .lifetime = .steady,                        .detail = "encoded PNG output bytes",                    },                },                .excluded = &.{                    "caller-owned RGBA input bytes",                    "filesystem and downstream decoder storage",                },            },            .capacity = .{                .inputs = &.{                    alloc_phase.capacity.bindInput(Limits, "image_width", "image.width"),                    alloc_phase.capacity.bindInput(Limits, "image_height", "image.height"),                    alloc_phase.capacity.bindInput(Limits, "image_rgba8", "image.rgba8"),                },                .type_selectors = &.{},                .nodes = &.{                    .{ .collection = .{ .length = 2 } },                    .{ .constant = 65536 },                    .{ .constant = 8192 },                    .{ .add = .{ .left = 1, .right = 2 } },                    .{ .add = .{ .left = 3, .right = 0 } },                },                .assertions = &.{.{                    .scope = .closure_total,                    .measure = .retained,                    .relation = .upper_bound,                    .expression = 4,                }},            },            .overload = .{                .kind = .reject_before_mutation,                .detail = "Bounds, input mismatch, and concurrent use reject before output mutation.",            },            .risks = .{                .transitive = .{                    .status = .witnessed,                    .detail = "Fixed regions cover scanlines, DEFLATE, chunk framing, and output.",                },                .foreign = .{                    .status = .excluded,                    .detail = "input ownership and output consumption remain caller effects",                },            },            .obligations = &.{                .{ .key = "png_encode_capacity", .role = .capacity_model },                .{ .key = "png_encode_acquisition", .role = .custom },                .{ .key = "png_encode_oom", .role = .custom },                .{ .key = "png_encode_boundaries", .role = .overload },                .{ .key = "png_encode_reuse", .role = .overload },                .{ .key = "png_encode_sealed", .role = .transitive_risk },                .{ .key = "png_encode_root", .role = .custom },                .{ .key = "png_encode_consumer", .role = .foreign_risk },            },        },        .bindings = .{            .owner = @This(),            .seal = .{                .family = alloc_phase.capacity.selector(@This().activate),                .premise = .{                    .class = .checked_semantic_fact,                    .authority = .checker,                },            },            .teardown = .{                .family = alloc_phase.capacity.selector(@This().deinit),                .premise = .{                    .class = .checked_semantic_fact,                    .authority = .checker,                },            },        },    };    pub fn init(allocator: std.mem.Allocator, limits: Limits) InitError!Storage {        const capacity = try Capacity.derive(limits);        const bytes = try allocator.alignedAlloc(            u8,            .fromByteUnits(capacity_mod.storage_alignment),            capacity.storage_bytes,        );        return .{            .phase = .initialization,            .capacity = capacity,            .bytes = bytes,            .window = bytes[capacity.window_offset..][0..flate.max_window_len],            .raw = bytes[capacity.raw_offset..][0..plan_mod.stream_bytes],            .count = bytes[capacity.count_offset..][0..plan_mod.stream_bytes],            .output = bytes[capacity.output_offset..][0..capacity.plan.output_bytes],        };    }    pub fn activate(self: *Storage) void {        std.debug.assert(self.phase == .initialization);        std.debug.assert(self.bytes.len == self.capacity.storage_bytes);        self.phase = .steady;    }    pub fn acquire(self: *Storage, image: model.ImageView) AcquireError!Regions {        std.debug.assert(self.phase == .steady);        if (self.in_use) return error.EncodeStorageInUse;        const actual = try plan_mod.Plan.inspectRegions(image, self.capacity.plan.bounds, .{            .window = self.window,            .raw = self.raw,            .count = self.count,        });        if (!std.meta.eql(actual, self.capacity.plan)) return error.EncodeInputMismatch;        self.in_use = true;        return .{ .window = self.window, .raw = self.raw, .output = self.output };    }    pub fn reset(self: *Storage) void {        std.debug.assert(self.phase == .steady);        std.debug.assert(self.in_use);        self.in_use = false;    }    pub fn status(self: *const Storage) Status {        return .{            .phase = self.phase,            .in_use = self.in_use,            .storage_bytes = self.capacity.storage_bytes,            .image_pixels = self.capacity.plan.image_pixels,            .raw_bytes = self.capacity.plan.raw_bytes,            .zlib_bytes = self.capacity.plan.zlib_bytes,            .output_bytes = self.capacity.plan.output_bytes,        };    }    pub fn deinit(self: *Storage, allocator: std.mem.Allocator) void {        std.debug.assert(self.phase != .teardown);        std.debug.assert(!self.in_use);        std.debug.assert(self.bytes.len == self.capacity.storage_bytes);        self.phase = .teardown;        allocator.free(self.bytes);        self.bytes = &.{};        self.window = &.{};        self.raw = &.{};        self.count = &.{};        self.output = &.{};    }};

Source: lib/png/src/root.zig:17

zig
pub const EncodeStorage = encode.Storage;
Called byCallsNo direct callstest sourcelib.png.src.encode.storagetest: PNG encode storage acquires one...EncodeStorageacquire
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callstest sourcelib.png.src.encode.storagetest: PNG encode storage acquires one...EncodeStorageactivate
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.png.src.encode.storagecheckInitFailurestest sourcelib.png.src.encode.storagetest: PNG encode storage acquires one...EncodeStoragedeinit
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callsprivate sourcelib.png.src.encode.storagecheckInitFailurestest sourcelib.png.src.encode.storagetest: PNG encode storage acquires one...EncodeStorageinit
Static calls · unresolved targets: 1 · external targets: 1.
Called byCallsNo direct callstest sourcelib.png.src.encode.storagetest: PNG encode storage acquires one...EncodeStoragereset
Static calls · unresolved targets: 0 · external targets: 0.

Also reachable as

encode.Storage.

Audit

Definitions13
Public names26
Members8
Version26.7.0
Revisiondaab053ee433