Skip to documentation
SLOP

tiny.http.ClientWebSocketStorage

Reference tiny.http ClientWebSocketStorage

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.httpClientWebSocketStorage
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/http/src/client/websocket/storage.zig:11

zig
pub const Storage = struct {    phase: alloc_phase.capacity.Phase,    capacity: model.Capacity,    bytes: []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_websocket_storage",            .kind = .phase_static,            .limit_source = .caller,            .storage = .{                .covered = &.{                    .{                        .id = "one_fixed_inbound_wire_frame_region_for_every_client_websocket",                        .lifetime = .steady,                        .detail = "one fixed inbound wire-frame region for every client WebSocket",                    },                    .{                        .id = "one_fixed_masked_outbound_wire_frame_region_for_eve_72613139f624",                        .lifetime = .steady,                        .detail = "one fixed masked outbound wire-frame region for every client WebSocket",                    },                },                .excluded = &.{                    "URL preparation, HTTP upgrade headers, TLS state, certificate bundles, sockets, and kernel queues",                    "application payload owners and protocol effects",                },            },            .capacity = .{                .inputs = &.{                    alloc_phase.capacity.bindInput(Limits, "websocket_count", "websocket_count"),                    alloc_phase.capacity.bindInput(Limits, "frame_payload_bytes_per_websocket", "frame_payload_bytes_per_websocket"),                },                .type_selectors = &.{},                .nodes = &.{                    .{ .input = 0 },                    .{ .scale = .{ .node = 0, .coefficient = .{ .literal = 2 } } },                    .{ .constant = 14 },                    .{ .input = 1 },                    .{ .add = .{ .left = 2, .right = 3 } },                    .{ .product = .{ .left = 1, .right = 4 } },                },                .assertions = &.{.{                    .scope = .closure_total,                    .measure = .retained,                    .relation = .exact,                    .expression = 5,                }},            },            .overload = .{                .kind = .terminal,                .detail = "capacity exhaustion rejects before opening a WebSocket or publishing a frame",            },            .risks = .{                .transitive = .{                    .status = .witnessed,                    .detail = "WebSocket frame send and receive allocate no storage after activation",                },                .foreign = .{                    .status = .excluded,                    .detail = "TLS and operating-system network owners remain independent",                },            },            .obligations = &.{                .{ .key = "http_client_websocket_capacity", .role = .capacity_model },                .{ .key = "http_client_websocket_oom_retry", .role = .custom },                .{ .key = "http_client_websocket_partition", .role = .overload },                .{ .key = "http_client_websocket_sealed", .role = .transitive_risk },                .{ .key = "http_client_websocket_network_overload", .role = .overload },                .{ .key = "http_client_websocket_network_transitive_risk", .role = .transitive_risk },                .{ .key = "http_client_websocket_network_foreign_risk", .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 = if (capacity.storage_bytes == 0)            @as([]u8, &.{})        else            try allocator.alloc(u8, 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 websocket(        self: *Storage,        index: usize,    ) StorageExhaustion!Scratch {        std.debug.assert(self.phase == .steady);        if (index >= self.capacity.websocket_count) {            return error.ClientWebSocketCapacityExceeded;        }        const frame_bytes =            self.capacity.frame_bytes_per_websocket;        const read_start = index * frame_bytes;        const write_region_start =            self.capacity.websocket_count * frame_bytes;        const write_start =            write_region_start + index * frame_bytes;        return .{            .read = self.bytes[read_start..][0..frame_bytes],            .write = self.bytes[write_start..][0..frame_bytes],            .frame_payload_bytes = self.capacity.frame_payload_bytes_per_websocket,        };    }    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:82

zig
pub const ClientWebSocketStorage = client.WebSocketStorage;
Called byCallsNo direct callstest sourcelib.http.src.client.websocket.storagetest: Client WebSocket storage partit...test sourcelib.http.src.client.websocket.storagetest: Client WebSocket storage remain...ClientWebSocketStorageactivate
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.http.src.client.websocket.storagecheckStorageInitFailurestest sourcelib.http.src.client.websocket.storagetest: Client WebSocket storage partit...test sourcelib.http.src.client.websocket.storagetest: Client WebSocket storage remain...ClientWebSocketStoragedeinit
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callsprivate sourcelib.http.src.client.websocket.storagecheckStorageInitFailurestest sourcelib.http.src.client.websocket.storagetest: Client WebSocket storage partit...test sourcelib.http.src.client.websocket.storagetest: Client WebSocket storage remain...ClientWebSocketStorageinit
Static calls · unresolved targets: 1 · external targets: 1.
Called byCallsNo direct callstest sourcelib.http.src.client.websocket.storagetest: Client WebSocket storage partit...test sourcelib.http.src.client.websocket.storagetest: Client WebSocket storage remain...ClientWebSocketStoragewebsocket
Static calls · unresolved targets: 0 · external targets: 0.

Audit

Definitions10
Public names10
Members3
Version26.7.0
Revisiondaab053ee433