Skip to documentation
SLOP

tiny.http.WebSocketStorage

Reference tiny.http WebSocketStorage

Defined in tiny.http.

API (13)

Actions

Public operations.

Types and contracts

Public types and contracts.

Fields and members

Public fields and members.

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

Source

Source: lib/http/src/websocket.zig:79

zig
pub const Storage = struct {    phase: alloc_phase.capacity.Phase,    capacity: StorageCapacity,    bytes: []u8,    pub const Limits: type = StorageLimits;    pub const Capacity: type = StorageCapacity;    pub const Exhaustion: type = StorageExhaustion;    pub const InitError = std.mem.Allocator.Error || error{CapacityOverflow};    pub const claim: alloc_phase.capacity.Declaration = .{        .source = .{            .id = "http.websocket_storage",            .kind = .phase_static,            .limit_source = .caller,            .storage = .{                .covered = &.{                    .{                        .id = "one_websocket_wire_frame_and_fragmented_message_byte_region",                        .lifetime = .steady,                        .detail = "one WebSocket wire-frame and fragmented-message byte region",                    },                },                .excluded = &.{                    "Connection unread bytes and router session objects",                    "caller-owned outbound payloads and handler-retained message copies",                    "socket and kernel queues, protocol callbacks, and application effects",                },            },            .capacity = .{                .inputs = &.{                    alloc_phase.capacity.bindInput(StorageLimits, "frame_payload_bytes", "frame_payload_bytes"),                    alloc_phase.capacity.bindInput(StorageLimits, "message_payload_bytes", "message_payload_bytes"),                },                .type_selectors = &.{},                .nodes = &.{                    .{ .constant = 14 },                    .{ .input = 0 },                    .{ .input = 1 },                    .{ .add = .{ .left = 0, .right = 1 } },                    .{ .add = .{ .left = 3, .right = 2 } },                },                .assertions = &.{.{                    .scope = .closure_total,                    .measure = .retained,                    .relation = .exact,                    .expression = 4,                }},            },            .overload = .{                .kind = .reject_before_mutation,                .detail = "oversize admission preserves prior fragmented-message bytes",            },            .risks = .{                .transitive = .{                    .status = .open,                    .detail = "router handlers can retain borrowed messages or allocate independently",                },                .foreign = .{                    .status = .open,                    .detail = "frame I/O crosses socket, kernel, scheduler, and peer storage",                },            },            .obligations = &.{                .{ .key = "http_websocket_capacity", .role = .capacity_model },                .{ .key = "http_websocket_oom_retry", .role = .custom },                .{ .key = "http_websocket_sealed", .role = .overload },                .{ .key = "http_websocket_fragmented", .role = .custom },                .{ .key = "http_websocket_upgrade", .role = .custom },                .{ .key = "http_websocket_semantics", .role = .custom },            },        },        .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: StorageLimits) InitError!Storage {        const capacity = try StorageCapacity.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 frame(self: *Storage, payload_bytes: usize) Exhaustion![]u8 {        std.debug.assert(self.phase != .teardown);        if (payload_bytes > self.capacity.frame_payload_bytes) {            return error.FramePayloadCapacityExceeded;        }        return self.bytes[0 .. maximum_frame_header_bytes + payload_bytes];    }    pub fn message(self: *Storage, payload_bytes: usize) Exhaustion![]u8 {        std.debug.assert(self.phase != .teardown);        if (payload_bytes > self.capacity.message_payload_bytes) {            return error.MessagePayloadCapacityExceeded;        }        const start = self.capacity.frame_bytes;        return self.bytes[start..][0..payload_bytes];    }    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:64

zig
pub const WebSocketStorage = websocket.Storage;
Called byCallsNo direct callstest sourcelib.http.src.websockettest: WebSocket storage retries after...test sourcelib.http.src.websockettest: WebSocket storage seals before ...WebSocketStorageactivate
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.http.src.websocketcheckStorageInitFailurestest sourcelib.http.src.websockettest: WebSocket storage retries after...test sourcelib.http.src.websockettest: WebSocket storage seals before ...WebSocketStoragedeinit
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callstest sourcelib.http.src.websockettest: WebSocket storage seals before ...WebSocketStorageframe
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.http.src.websocketcheckStorageInitFailurestest sourcelib.http.src.websockettest: WebSocket storage retries after...test sourcelib.http.src.websockettest: WebSocket storage seals before ...WebSocketStorageinit
Static calls · unresolved targets: 1 · external targets: 1.
Called byCallsNo direct callstest sourcelib.http.src.websockettest: WebSocket storage seals before ...WebSocketStoragemessage
Static calls · unresolved targets: 0 · external targets: 0.

Also reachable as

WebsocketStorage.

Audit

Definitions11
Public names22
Members3
Version26.7.0
Revisiondaab053ee433