tiny.http.ConnectionInputStorage
Defined in tiny.http.
API (12)
Actions
Public operations.
Types and contracts
Public types and contracts.
Fields and members
Public fields and members.
Source
Source: lib/http/src/connection.zig:43
zig
pub const InputStorage = struct { phase: alloc_phase.capacity.Phase, capacity: StorageCapacity, bytes: []u8, pub const Limits: type = StorageLimits; pub const Capacity: type = StorageCapacity; pub const Exhaustion: type = InputExhaustion; pub const InitError = std.mem.Allocator.Error || error{CapacityOverflow}; pub const claim: alloc_phase.capacity.Declaration = .{ .source = .{ .id = "http.connection_input_storage", .kind = .phase_static, .limit_source = .caller, .storage = .{ .covered = &.{ .{ .id = "fixed_retained_input_byte_region_for_every_connection_slot", .lifetime = .steady, .detail = "fixed retained-input byte region for every connection slot", }, }, .excluded = &.{ "request header-map buckets and decoded chunked-body output", "WebSocket storage, protocol sessions, handlers, and response output", "socket and kernel queues", }, }, .capacity = .{ .inputs = &.{ alloc_phase.capacity.bindInput(Limits, "connection_count", "connection_count"), alloc_phase.capacity.bindInput(Limits, "bytes_per_connection", "bytes_per_connection"), }, .type_selectors = &.{}, .nodes = &.{ .{ .input = 0 }, .{ .input = 1 }, .{ .product = .{ .left = 0, .right = 1 } }, }, .assertions = &.{.{ .scope = .closure_total, .measure = .retained, .relation = .exact, .expression = 2, }}, }, .overload = .{ .kind = .reject_before_mutation, .detail = "full input preserves retained bytes and leaves foreign input unread", }, .risks = .{ .transitive = .{ .status = .open, .detail = "request parsing and installed protocol callbacks own separate storage", }, .foreign = .{ .status = .open, .detail = "input admission reads from socket and kernel storage", }, }, .obligations = &.{ .{ .key = "http_connection_input_capacity", .role = .capacity_model }, .{ .key = "http_connection_input_oom_retry", .role = .custom }, .{ .key = "http_connection_input_partition", .role = .custom }, .{ .key = "http_connection_input_sealed", .role = .overload }, .{ .key = "http_connection_input_partial", .role = .custom }, .{ .key = "http_connection_input_pipeline", .role = .custom }, .{ .key = "http_connection_input_overload", .role = .custom }, .{ .key = "http_connection_input_accept", .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!InputStorage { 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: *InputStorage) void { std.debug.assert(self.phase == .initialization); std.debug.assert(self.bytes.len == self.capacity.storage_bytes); self.phase = .steady; } pub fn connection(self: *InputStorage, index: usize) Exhaustion![]u8 { std.debug.assert(self.phase == .steady); if (index >= self.capacity.connection_count) { return error.ConnectionCapacityExceeded; } const start = index * self.capacity.bytes_per_connection; return self.bytes[start..][0..self.capacity.bytes_per_connection]; } pub fn deinit(self: *InputStorage, 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:33
zig
pub const ConnectionInputStorage = connection.InputStorage;Audit
| Definitions | 10 |
|---|---|
| Public names | 10 |
| Members | 3 |
| Version | 26.7.0 |
| Revision | daab053ee433 |