Declaraciones públicas de zig/wire.zig (conduit-zig (SDK consumido)).
apps/docs/generated/zig/conduit.jsonPágina generada desde
conduit@conduit-0.1.0-f7J_7zg5DwCsHBHItwdOz9ZVq8cvH7ceFsk7-m3-T61t (zig/root.zig). No se edita a mano:bun run docs:genla regenera ybun run docs:checkfalla si difiere.
conduit wire v1 — the single codec shared by the client and the server.
Normative text: spec/wire-v1.md. Conformance: spec/vectors/wire-v1.json
(run by wire_vectors_test.zig here and by @mks2508/chunk-engine in TS).
Everything here parses input that crosses a trust boundary (styx dec-0117
B4/I5): every length and offset is bounds-checked with overflow-checked
arithmetic, nothing unreachables on input, errors are typed. The module
is freestanding-clean (no OS calls): it also builds for wasm32.
wire.versionconst · línea 15
pub const version: u32 = 1Sin ///.
wire.max_safe_integerconst · línea 17
pub const max_safe_integer: u64 = (1 << 53) - 1JSON integers must fit a JavaScript number exactly (Number.MAX_SAFE_INTEGER).
wire.max_request_jsonconst · línea 19
pub const max_request_json: usize = 4096Request JSON bodies over this size are rejected before parsing.
wire.default_baseconst · línea 20
pub const default_base = "/api/upload"Sin ///.
wire.max_filename_lenconst · línea 21
pub const max_filename_len = 255Sin ///.
wire.Digestconst · línea 23
pub const Digest = [Sha256.digest_length]u8Sin ///.
wire.hex_digest_lenconst · línea 24
pub const hex_digest_len = 64Sin ///.
wire.content_digest_lenconst · línea 26
pub const content_digest_len = 9 + 44 + 1sha-256=: + 44 base64 chars + :.
wire.max_content_range_lenconst · línea 28
pub const max_content_range_len = 6 + 16 + 1 + 16 + 1 + 16bytes + 3 × 16 digits + - + /.
wire.ErrorCodetype · línea 33
pub const ErrorCode = enumWire error codes (spec §5). The tag name is the JSON error string.
wire.ErrorCode.httpStatusfn · línea 58
pub fn httpStatus(c: ErrorCode) u16Sin ///.
wire.ErrorCode.retryablefn · línea 73
pub fn retryable(c: ErrorCode) boolSin ///.
wire.ErrorCode.fromNamefn · línea 80
pub fn fromName(name: []const u8) ?ErrorCodeSin ///.
wire.ErrorCode.retryableStatusfn · línea 86
pub fn retryableStatus(status: u16) boolClassification of a response whose code this client does not know: 5xx and 429 retry, everything else is final (spec §5).
wire.ParseErrorconst · línea 91
pub const ParseError = error{Invalid}Sin ///.
wire.UploadIdtype · línea 95
pub const UploadId = structSin ///.
wire.UploadId.min_lenconst · línea 96
pub const min_len = 8Sin ///.
wire.UploadId.max_lenconst · línea 97
pub const max_len = 64Sin ///.
wire.UploadId.parsefn · línea 102
pub fn parse(s: []const u8) ParseError!UploadIdSin ///.
wire.UploadId.slicefn · línea 114
pub fn slice(self: *const UploadId) []const u8Sin ///.
wire.UploadId.eqlfn · línea 118
pub fn eql(a: *const UploadId, b: *const UploadId) boolSin ///.
wire.parseDecimalfn · línea 128
pub fn parseDecimal(s: []const u8, max_digits: usize) ParseError!u64Strict unsigned decimal: no sign, no leading zeros, at most max_digits.
wire.parseIndexfn · línea 141
pub fn parseIndex(s: []const u8) ParseError!u32Chunk index from a path segment (spec §3).
wire.validateFilenamefn · línea 147
pub fn validateFilename(name: []const u8) ParseError!voidFilename rules (spec §3). The name is metadata; it is never a path.
wire.Rangetype · línea 158
pub const Range = structSin ///.
wire.Range.endfn · línea 163
pub fn end(r: Range) u64Inclusive end (Content-Range). Only valid for len > 0.
wire.PlanErrorconst · línea 168
pub const PlanError = error{ InvalidSize, InvalidChunkSize, TooManyChunks }Sin ///.
wire.Plantype · línea 172
pub const Plan = structtotalChunks = ceil(size / chunkSize); chunk i covers
[i·chunkSize, min((i+1)·chunkSize, size)) (spec §6.1).
wire.Plan.initfn · línea 177
pub fn init(total_size: u64, chunk_size: u64, max_chunks: u32) PlanError!PlanSin ///.
wire.Plan.chunkfn · línea 187
pub fn chunk(p: Plan, index: u32) ?Rangenull if index is not a chunk of this plan.
wire.ContentRangetype · línea 197
pub const ContentRange = structSin ///.
wire.ContentRange.parsefn · línea 204
pub fn parse(s: []const u8) ParseError!ContentRangeStrict bytes <start>-<end>/<total> (spec §4.2): no spaces, no *,
no leading zeros, start ≤ end < total ≤ 2^53−1.
wire.ContentRange.ofChunkfn · línea 218
pub fn ofChunk(p: Plan, index: u32) ?ContentRangeSin ///.
wire.ContentRange.formatfn · línea 223
pub fn format(cr: ContentRange, buf: *[max_content_range_len]u8) []const u8Sin ///.
wire.ContentRange.eqlfn · línea 227
pub fn eql(a: ContentRange, b: ContentRange) boolSin ///.
wire.parseContentDigestfn · línea 237
pub fn parseContentDigest(s: []const u8) ParseError!DigestRFC 9530 Content-Digest with exactly one sha-256 member.
wire.formatContentDigestfn · línea 253
pub fn formatContentDigest(d: Digest, buf: *[content_digest_len]u8) []const u8Sin ///.
wire.hexDigestfn · línea 260
pub fn hexDigest(d: Digest) [hex_digest_len]u8Sin ///.
wire.parseHexDigestfn · línea 265
pub fn parseHexDigest(s: []const u8) ParseError!DigestLowercase hex only (spec §4.1).
wire.Methodtype · línea 275
pub const Method = enumSin ///.
wire.Routetype · línea 277
pub const Route = unionSin ///.
wire.RouteErrorconst · línea 285
pub const RouteError = error{ NotFound, BadRequest }Sin ///.
wire.routefn · línea 290
pub fn route(base: []const u8, method: Method, path: []const u8) RouteError!RouteResolve path (raw request target) under base (spec §4). Routing is by
method and segment count; ids and indices are validated here, so nothing
downstream ever sees an unvalidated path component.
wire.max_path_lenconst · línea 324
pub const max_path_len = 1 + 8 + 1 + UploadId.max_len + 1 + 10Sin ///.
wire.formatPathfn · línea 327
pub fn formatPath(r: Route, buf: *[max_path_len]u8) []const u8Path of r relative to the base (e.g. /chunk/<id>/3).
wire.bearerTokenfn · línea 340
pub fn bearerToken(header: ?[]const u8) ?[]const u8Token of an Authorization: Bearer <token> header; null for anything
else (spec §2: missing, other scheme or empty ⇒ 401).
wire.CreateRequesttype · línea 351
pub const CreateRequest = structSin ///.
wire.SessionResponsetype · línea 358
pub const SessionResponse = structSin ///.
wire.ChunkResponsetype · línea 367
pub const ChunkResponse = structSin ///.
wire.SessionStatustype · línea 373
pub const SessionStatus = enumSin ///.
wire.StatusResponsetype · línea 375
pub const StatusResponse = structSin ///.
wire.CompleteResponsetype · línea 384
pub const CompleteResponse = structSin ///.
wire.ErrorBodytype · línea 391
pub const ErrorBody = structSin ///.
wire.DecodeErrorconst · línea 396
pub const DecodeError = error{ Invalid, OutOfMemory }Sin ///.
wire.parseValuefn · línea 400
pub fn parseValue(arena: std.mem.Allocator, bytes: []const u8) DecodeError!std.json.ObjectMapSin ///.
wire.getIntfn · línea 415
pub fn getInt(o: std.json.ObjectMap, key: []const u8) ParseError!u64Sin ///.
wire.getOptIntfn · línea 419
pub fn getOptInt(o: std.json.ObjectMap, key: []const u8) ParseError!?u64Sin ///.
wire.intOffn · línea 424
pub fn intOf(v: Value) ParseError!u64Sin ///.
wire.getStringfn · línea 434
pub fn getString(o: std.json.ObjectMap, key: []const u8) ParseError![]const u8Sin ///.
wire.getOptStringfn · línea 441
pub fn getOptString(o: std.json.ObjectMap, key: []const u8) ParseError!?[]const u8Sin ///.
wire.decodeCreateRequestfn · línea 450
pub fn decodeCreateRequest(arena: std.mem.Allocator, bytes: []const u8) DecodeError!CreateRequestServer side: POST {base}/session body. Strings in the result point into
arena.
wire.decodeCreateObjectfn · línea 457
pub fn decodeCreateObject(o: std.json.ObjectMap) ParseError!CreateRequestdecodeCreateRequest on an already parsed body (wire v2 parses once and
dispatches on protocol).
wire.decodeCompleteRequestfn · línea 472
pub fn decodeCompleteRequest(arena: std.mem.Allocator, bytes: []const u8) DecodeError!?DigestServer side: optional POST {base}/complete/{id} body {"sha256":…}.
Empty body ⇒ null.
wire.decodeSessionResponsefn · línea 480
pub fn decodeSessionResponse(arena: std.mem.Allocator, bytes: []const u8) DecodeError!SessionResponseSin ///.
wire.decodeChunkResponsefn · línea 500
pub fn decodeChunkResponse(arena: std.mem.Allocator, bytes: []const u8) DecodeError!ChunkResponseSin ///.
wire.decodeStatusResponsefn · línea 509
pub fn decodeStatusResponse(arena: std.mem.Allocator, bytes: []const u8) DecodeError!StatusResponseSin ///.
wire.decodeCompleteResponsefn · línea 536
pub fn decodeCompleteResponse(arena: std.mem.Allocator, bytes: []const u8) DecodeError!CompleteResponseSin ///.
wire.decodeErrorBodyfn · línea 548
pub fn decodeErrorBody(arena: std.mem.Allocator, bytes: []const u8) ErrorBodyError bodies are best-effort: an unparseable body still has a status.
wire.encodeCreateRequestfn · línea 561
pub fn encodeCreateRequest(w: *Writer, r: CreateRequest) Writer.Error!voidSin ///.
wire.encodeCompleteRequestfn · línea 569
pub fn encodeCompleteRequest(w: *Writer, root_digest: Digest) Writer.Error!voidSin ///.
wire.encodeSessionResponsefn · línea 573
pub fn encodeSessionResponse(w: *Writer, r: SessionResponse) Writer.Error!voidSin ///.
wire.encodeChunkResponsefn · línea 584
pub fn encodeChunkResponse(w: *Writer, r: ChunkResponse) Writer.Error!voidSin ///.
wire.encodeStatusResponsefn · línea 590
pub fn encodeStatusResponse(w: *Writer, r: StatusResponse) Writer.Error!voidSin ///.
wire.encodeCompleteResponsefn · línea 601
pub fn encodeCompleteResponse(w: *Writer, r: CompleteResponse) Writer.Error!voidSin ///.
wire.encodeAbortResponsefn · línea 609
pub fn encodeAbortResponse(w: *Writer, id: UploadId) Writer.Error!voidSin ///.
wire.encodeErrorfn · línea 615
pub fn encodeError(w: *Writer, code: ErrorCode, message: []const u8) Writer.Error!voidSin ///.
wire.formatRfc3339fn · línea 622
pub fn formatRfc3339(unix_seconds: u64, buf: *[20]u8) []const u8RFC 3339 UTC (2026-09-29T10:00:00Z) of a Unix time in seconds.
wire.sha256fn · línea 632
pub fn sha256(bytes: []const u8) DigestSin ///.
wire.backoffMsfn · línea 640
pub fn backoffMs(attempt: u32) u32Exponential backoff for retry attempt (1-based): 250 ms · 2^(n−1),
capped at 10 s. Hosts add jitter.