Skip to documentation
SLOP

tiny.http.ClientStreamStorage

Reference tiny.http ClientStreamStorage

Defined in tiny.http.

API (12)

Actions

Public operations.

Types and contracts

Public types and contracts.

Fields and members

Public fields and members.

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

Source

Source: lib/http/src/client/stream/storage.zig:10

zig
pub const Storage = struct {    phase: alloc_phase.capacity.Phase,    capacity: model.Capacity,    bytes: []align(@alignOf(Header)) u8,    pub const Limits: type = model.Limits;    pub const Capacity: type = model.Capacity;    pub const Exhaustion: type = StorageExhaustion;    pub const InitError = std.mem.Allocator.Error || error{CapacityOverflow};    pub const claim: alloc_phase.capacity.Declaration = .{        .source = .{            .id = "http.client_stream_storage",            .kind = .phase_static,            .limit_source = .caller,            .storage = .{                .covered = &.{                    .{                        .id = "fixed_parsed_streaming_response_header_entries_for_e9a56e6dd10f",                        .lifetime = .steady,                        .detail = "fixed parsed streaming-response header entries for every stream slot",                    },                    .{                        .id = "fixed_response_head_bytes_retaining_borrowed_callba_581ad8ca32dc",                        .lifetime = .steady,                        .detail = "fixed response-head bytes retaining borrowed callback header names and values",                    },                },                .excluded = &.{                    "request serialization, URL targets, TLS state, certificate bundles, sockets, and kernel queues",                    "fixed scalar chunk-fragmentation state and handler-owned streamed output",                },            },            .capacity = .{                .inputs = &.{                    alloc_phase.capacity.bindInput(Limits, "stream_count", "stream_count"),                    alloc_phase.capacity.bindInput(Limits, "header_count_per_stream", "header_count_per_stream"),                    alloc_phase.capacity.bindInput(Limits, "head_bytes_per_stream", "head_bytes_per_stream"),                },                .type_selectors = &.{                    alloc_phase.capacity.bindType(Header, "header"),                },                .nodes = &.{                    .{ .input = 0 },                    .{ .input = 1 },                    .{ .product = .{ .left = 0, .right = 1 } },                    .{ .constant = 1 },                    .{ .scale = .{ .node = 3, .coefficient = .{ .size_of_concrete_type = 0 } } },                    .{ .product = .{ .left = 2, .right = 4 } },                    .{ .input = 2 },                    .{ .product = .{ .left = 0, .right = 6 } },                    .{ .add = .{ .left = 5, .right = 7 } },                },                .assertions = &.{.{                    .scope = .closure_total,                    .measure = .retained,                    .relation = .exact,                    .expression = 8,                }},            },            .overload = .{                .kind = .terminal,                .detail = "an over-capacity response terminates that one-shot stream before publishing the head callback",            },            .risks = .{                .transitive = .{                    .status = .witnessed,                    .detail = "stream head parsing and fragmented chunk decoding allocate no storage after activation",                },                .foreign = .{                    .status = .excluded,                    .detail = "handler callbacks own any retained headers or body output and preserve their own error identity",                },            },            .obligations = &.{                .{ .key = "http_client_stream_capacity", .role = .capacity_model },                .{ .key = "http_client_stream_oom_retry", .role = .custom },                .{ .key = "http_client_stream_partition", .role = .custom },                .{ .key = "http_client_stream_sealed", .role = .transitive_risk },                .{ .key = "http_client_stream_atomic", .role = .overload },                .{ .key = "http_client_stream_boundary", .role = .custom },                .{ .key = "http_client_stream_callback", .role = .foreign_risk },                .{ .key = "http_client_stream_network", .role = .overload },            },        },        .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 = if (capacity.storage_bytes == 0)            @as([]align(@alignOf(Header)) u8, &.{})        else            try allocator.alignedAlloc(u8, .of(Header), capacity.storage_bytes);        return .{            .phase = .initialization,            .capacity = capacity,            .bytes = 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 stream(self: *Storage, index: usize) Exhaustion!Scratch {        std.debug.assert(self.phase == .steady);        if (index >= self.capacity.stream_count) {            return error.ClientStreamCapacityExceeded;        }        const all_headers = std.mem.bytesAsSlice(            Header,            self.bytes[0..self.capacity.header_bytes],        );        const header_start = index * self.capacity.header_count_per_stream;        const head_start = self.capacity.header_bytes +            index * self.capacity.head_bytes_per_stream;        return .{            .headers = all_headers[header_start..][0..self.capacity.header_count_per_stream],            .head = self.bytes[head_start..][0..self.capacity.head_bytes_per_stream],        };    }    pub fn deinit(self: *Storage, allocator: std.mem.Allocator) void {        std.debug.assert(self.phase != .teardown);        std.debug.assert(self.bytes.len == self.capacity.storage_bytes);        self.phase = .teardown;        if (self.bytes.len != 0) allocator.free(self.bytes);        self.bytes = &.{};    }};

Source: lib/http/src/root.zig:107

zig
pub const ClientStreamStorage = client.StreamStorage;
Called byCallsNo direct callstest sourcelib.http.src.client.stream.storagetest: Client stream storage partition...test sourcelib.http.src.client.stream.storagetest: Client streaming remains alloca...ClientStreamStorageactivate
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.http.src.client.stream.storagecheckStorageInitFailurestest sourcelib.http.src.client.stream.storagetest: Client stream storage partition...test sourcelib.http.src.client.stream.storagetest: Client streaming remains alloca...ClientStreamStoragedeinit
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callsprivate sourcelib.http.src.client.stream.storagecheckStorageInitFailurestest sourcelib.http.src.client.stream.storagetest: Client stream storage partition...test sourcelib.http.src.client.stream.storagetest: Client streaming remains alloca...ClientStreamStorageinit
Static calls · unresolved targets: 2 · external targets: 1.
Called byCallsNo direct callstest sourcelib.http.src.client.stream.storagetest: Client stream storage partition...test sourcelib.http.src.client.stream.storagetest: Client streaming remains alloca...ClientStreamStoragestream
Static calls · unresolved targets: 0 · external targets: 0.

Audit

Definitions10
Public names10
Members3
Version26.7.0
Revisiondaab053ee433