Referencia Zigconduit-zig (SDK consumido)

zig/wire_v2.zig

Declaraciones públicas de zig/wire_v2.zig (conduit-zig (SDK consumido)).

ImplementadoSin versión del tren todavía· generada desde apps/docs/generated/zig/conduit.json

Página generada desde conduit@conduit-0.1.0-f7J_7zg5DwCsHBHItwdOz9ZVq8cvH7ceFsk7-m3-T61t (zig/root.zig). No se edita a mano: bun run docs:gen la regenera y bun run docs:check falla si difiere.

conduit wire v2 — the codec of what v2 adds to v1 in mode chunks (spec/wire-v2.md §1, §4, §5.4, §10): the create body with "protocol":2, the v2 session/status/complete responses, the Conduit-Chunk-Cv header and the stored bitmap. Everything else (ids, routes, Content-Range, error bodies, the chunk response) is v1's, in wire.zig.

Negotiation (§1): a body or response without protocol is v1 and decodes exactly as wire.zig does; decode*Any return which one it was.

Same rules as wire.zig (styx dec-0117 B4/I5): exact lengths, lowercase hex only, overflow-checked integers, no unreachable on input, freestanding-clean. Mode blobs is parsed (so a server can refuse it precisely) but its manifest and blob routes are not here yet.

wire_v2.protocol

const · línea 24

pub const protocol: u64 = 2

Sin ///.

wire_v2.chunk_cv_header

const · línea 26

pub const chunk_cv_header = "Conduit-Chunk-Cv"

Sin ///.

wire_v2.hex_cv_len

const · línea 27

pub const hex_cv_len = 64

Sin ///.

wire_v2.validChunkSize

fn · línea 35

pub fn validChunkSize(cs: u64) bool

chunkSize rule of v2 (§4.1): a power of two ≥ 16 KiB (and a JSON-safe integer), so every chunk is a subtree of the file's BLAKE3 tree.

wire_v2.parseCv

fn · línea 40

pub fn parseCv(s: []const u8) ParseError!Cv

Conduit-Chunk-Cv / root / blobId: exactly 64 lowercase hex characters.

wire_v2.hexCv

fn · línea 44

pub fn hexCv(cv: Cv) [hex_cv_len]u8

Sin ///.

wire_v2.bitmapLen

fn · línea 52

pub fn bitmapLen(n: u64) u64

Sin ///.

wire_v2.writeBitmap

fn · línea 58

pub fn writeBitmap(w: *Writer, n: u64, ctx: anytype, comptime isSet: fn (@TypeOf(ctx), u64) bool) Writer.Error!void

Base64 of the bitmap of n bits whose bit i is isSet(ctx, i), streamed three bytes at a time (no buffer proportional to n).

wire_v2.decodeBitmap

fn · línea 79

pub fn decodeBitmap(arena: std.mem.Allocator, s: []const u8, n: u64) DecodeError![]u8

Bitmap bytes of n bits from canonical base64 (§5.4): exact length, padding, no spare bit set, canonical encoding. Allocated in arena.

wire_v2.bitIsSet

fn · línea 96

pub fn bitIsSet(bitmap: []const u8, i: u64) bool

Sin ///.

wire_v2.Mode

type · línea 102

pub const Mode = enum

Sin ///.

wire_v2.Encodings

type · línea 104

pub const Encodings = struct

Sin ///.

wire_v2.CreateV2

type · línea 109

pub const CreateV2 = struct

Sin ///.

wire_v2.Create

type · línea 121

pub const Create = union

Sin ///.

wire_v2.decodeCreateAny

fn · línea 127

pub fn decodeCreateAny(arena: std.mem.Allocator, bytes: []const u8) DecodeError!Create

Server side: a create body of either protocol. Strings point into arena.

wire_v2.encodeCreate

fn · línea 175

pub fn encodeCreate(w: *Writer, c: CreateV2) Writer.Error!void

Client side, byte-identical to the TS codec (vectors createSession.encode).

wire_v2.Have

type · línea 190

pub const Have = enum

Sin ///.

wire_v2.SessionV2

type · línea 192

pub const SessionV2 = struct

Sin ///.

wire_v2.Session

type · línea 207

pub const Session = union

Sin ///.

wire_v2.encodeSession

fn · línea 212

pub fn encodeSession(w: *Writer, r: SessionV2) Writer.Error!void

Sin ///.

wire_v2.decodeSessionAny

fn · línea 230

pub fn decodeSessionAny(arena: std.mem.Allocator, bytes: []const u8) DecodeError!Session

Client side: the create response of either protocol (§1: no protocol field = the server spoke v1).

wire_v2.StatusV2

type · línea 276

pub const StatusV2 = struct

Sin ///.

wire_v2.Status

type · línea 287

pub const Status = union

Sin ///.

wire_v2.encodeStatus

fn · línea 293

pub fn encodeStatus(w: *Writer, id: wire.UploadId, mode: Mode, total: u64, confirmed: u64, status: wire.SessionStatus, ctx: anytype, comptime isSet: fn (@TypeOf(ctx), u64) bool) Writer.Error!void

Server side: status with the bitmap streamed from isSet(ctx, i).

wire_v2.decodeStatusAny

fn · línea 301

pub fn decodeStatusAny(arena: std.mem.Allocator, bytes: []const u8) DecodeError!Status

Sin ///.

wire_v2.encodeCompleteRequest

fn · línea 323

pub fn encodeCompleteRequest(w: *Writer, root: Cv) Writer.Error!void

Sin ///.

wire_v2.decodeCompleteRequest

fn · línea 329

pub fn decodeCompleteRequest(arena: std.mem.Allocator, bytes: []const u8) DecodeError!?Cv

Server side: optional body {"root":…}; empty body ⇒ null. A v1 sha256 in a v2 session is refused (one identity per session).

wire_v2.CompleteV2

type · línea 338

pub const CompleteV2 = struct

Sin ///.

wire_v2.Complete

type · línea 345

pub const Complete = union

Sin ///.

wire_v2.encodeComplete

fn · línea 350

pub fn encodeComplete(w: *Writer, r: CompleteV2) Writer.Error!void

Sin ///.

wire_v2.decodeCompleteAny

fn · línea 358

pub fn decodeCompleteAny(arena: std.mem.Allocator, bytes: []const u8) DecodeError!Complete

Sin ///.

wire_v2.chunkHasher

fn · línea 375

pub fn chunkHasher(plan: wire.Plan, index: u32) ?tree.SubtreeHasher

Range of chunk index of a v2 plan (wire.Plan with a valid v2 chunk size): an aligned subtree, the last one possibly shorter.