Declaraciones públicas de zig/dedup.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.
Dedup domains and the index a v2 server consults for have
(spec/wire-v2.md §6).
A have answer tells the client whether the server already holds some
bytes. Unrestricted, that is a confirmation-of-file oracle (does anybody
here hold this exact file?), a learn-the-remaining-information oracle (which
of 10⁶ variants of a template "already exists"?) and, if a have let a
client attach bytes it never sent, a hash used as a read capability. The
rules this module makes structural:
Authorizer grants a Domain with each credential: none, the
subject (default) or a shared opaque id whose members can already
read every object of the domain (a styx household). scope resolves it
to an injective Scope (the kind is part of the key, so a subject and a
shared id with the same bytes never meet);Index call takes exactly one Scope; there is no call that
searches "anywhere". MemoryIndex keeps one table per scope and a
lookup touches only the caller's table: other domains change no answer,
no error and no timing on the request path;MemoryIndex.Limits): objects and
blobs per scope, scopes in total, bytes of bookkeeping. A domain that
fills its share loses dedup for itself only (record refuses), never
space of other domains;invalidate, the index
forgets that location (MemoryIndex: the whole object) and a later
upload that resends those bytes records them afresh. An object
announced and lost before complete is a retryable 409 incomplete,
never a failed or wrong file (spec §4.4, §5.5);The index is an interface because the authority over "what does this
domain hold" belongs to the consumer (styx: the catalog of a household).
MemoryIndex is the reference implementation (CLI serve, tests): objects
are entries of a zkit.safety.fs.Root, read fd-relative (styx dec-0117 I7).
dedup.Idconst · línea 49
pub const Id = [32]u8B3(bytes): a blob id or the root of a file.
dedup.hashfn · línea 51
pub fn hash(bytes: []const u8) IdSin ///.
dedup.Domaintype · línea 58
pub const Domain = unionThe dedup domain a grant gives (spec §6.1).
dedup.Scopetype · línea 69
pub const Scope = structA resolved dedup domain: the key every index operation is confined to.
dedup.Scope.Kindtype · línea 73
pub const Kind = enumSin ///.
dedup.Scope.eqlfn · línea 75
pub fn eql(a: Scope, b: Scope) boolSin ///.
dedup.scopefn · línea 81
pub fn scope(domain: Domain, subject: [32]u8) ?Scopenull = no dedup for this grant.
dedup.BlobReftype · línea 90
pub const BlobRef = structA blob by content: its id and its exact length.
dedup.Objecttype · línea 93
pub const Object = structA completed object, as recorded after complete.
dedup.Staletype · línea 108
pub const Stale = unionWhat the store failed to give back (Index.invalidate).
dedup.ReadErrorconst · línea 115
pub const ReadError = error{ /// Not held (any more) in that scope. NotFound, /// The object could not be read in full. ReadFailed, }Sin ///.
dedup.RecordErrorconst · línea 122
pub const RecordError = error{ /// The scope already holds all its share (`MemoryIndex.Limits`). QuotaExceeded, /// Bookkeeping budget exhausted. OutOfMemory, /// Inconsistent object (lengths, spans o …Sin ///.
dedup.Indextype · línea 133
pub const Index = structWhat a server asks about a domain. Every call is confined to s.
Implementations must be thread-safe and must not look at other scopes.
dedup.Index.VTabletype · línea 137
pub const VTable = structSin ///.
dedup.Index.hasObjectfn · línea 162
pub fn hasObject(ix: Index, s: Scope, root: Id, size: u64) boolSin ///.
dedup.Index.hasBlobsfn · línea 166
pub fn hasBlobs(ix: Index, s: Scope, blobs: []const BlobRef, held: []bool) voidSin ///.
dedup.Index.readBlobfn · línea 171
pub fn readBlob(ix: Index, s: Scope, b: BlobRef, offset: u64, dest: []u8) ReadError!voidSin ///.
dedup.Index.readObjectfn · línea 175
pub fn readObject(ix: Index, s: Scope, root: Id, size: u64, offset: u64, dest: []u8) ReadError!voidSin ///.
dedup.Index.invalidatefn · línea 179
pub fn invalidate(ix: Index, s: Scope, stale: Stale) voidSin ///.
dedup.Index.recordfn · línea 183
pub fn record(ix: Index, s: Scope, o: Object) RecordError!voidSin ///.
dedup.CopyErrorconst · línea 188
pub const CopyError = error{ /// The store no longer gives the object's exact bytes. The object is /// invalidated already: answer `409 incomplete` and go on as `have: /// "none"` (nothing stored; the …Sin ///.
dedup.copyHeldObjectfn · línea 202
pub fn copyHeldObject(ix: Index, s: Scope, root: Id, size: u64, file: zfs.File, buf: []u8) CopyError!voidFinalize from held (§4.4, have: "all"): copies the object root/size
of s into file from offset 0, hashing it as it goes, and checks the
hash is root. hasObject answered at create; the object may have gone
or changed since, so the copy is what proves it. On Lost the object is
already invalidated, so the next create answers have: "none".
dedup.MemoryIndextype · línea 231
pub const MemoryIndex = structIn-memory index over the objects of a Root (reference server, tests).
Sessions do not survive a restart and neither does this index: a consumer
that wants dedup across restarts implements Index over its catalog.
dedup.MemoryIndex.Limitstype · línea 232
pub const Limits = structSin ///.
dedup.MemoryIndex.max_key_lenconst · línea 243
pub const max_key_len = 256Sin ///.
dedup.MemoryIndex.initfn · línea 269
pub fn init(self: *MemoryIndex, gpa: Allocator, root: *const Root, limits: Limits) error{InvalidLimits}!voidself must not move after init (index() points at it).
dedup.MemoryIndex.deinitfn · línea 279
pub fn deinit(self: *MemoryIndex) zkit.safety.LeakReportFrees everything; the report says whether the bookkeeping was clean.
dedup.MemoryIndex.indexfn · línea 291
pub fn index(self: *MemoryIndex) IndexSin ///.
dedup.MemoryIndex.Usagetype · línea 309
pub const Usage = structSin ///.
dedup.MemoryIndex.usagefn · línea 312
pub fn usage(self: *MemoryIndex, s: Scope) UsageObjects and distinct blobs recorded for s (tests, metrics).
blobs.Idconst · línea 49
pub const Id = [32]u8B3(bytes): a blob id or the root of a file.
blobs.BlobReftype · línea 90
pub const BlobRef = structA blob by content: its id and its exact length.