Skip to documentation
SLOP

tiny.content.Reader

Reference tiny.content Reader

Defined in tiny.content.

Read capability over one provider, for a holder that reopens bytes it already has a reference for.

API (5)

Actions

Public operations.

Types and contracts

Public types and contracts.

Fields and members

Public fields and members.

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

Source

Source: lib/content/src/capability.zig:41

zig
/// Read capability over one provider, for a holder that reopens bytes it/// already has a reference for. The capability carries three things: the/// capacity the store was built with, a function table whose single entry reads/// by identifier, and an opaque context pointer borrowed from the provider that/// produced it, so the provider outlives the Reader.pub const Reader = struct {    context: *anyopaque,    capacity: model.Capacity,    vtable: *const VTable,    pub const VTable: type = ReaderVTable;    /// Reopens the bytes of one reference into buffer storage the caller owns    /// and returns the slice that was checked. The function rejects a reference    /// whose extent is above the capacity's per-object byte limit, the *object    /// ceiling*, with `ContentExtentExceeded` before it touches the provider,    /// and it reports `CallerBufferTooSmall` when the buffer is shorter than    /// the reference extent. The provider receives a slice cut to exactly that    /// extent. The call reports `ContentTruncated` when the provider returns    /// fewer bytes than the extent and `ContentExtentMismatch` when it returns    /// more, and then rehashes what came back and reports    /// `ContentIdentifierMismatch` when the digest disagrees, so a provider    /// that returns the wrong bytes is caught here.    pub fn read(        self: Reader,        reference: model.Reference,        output: []u8,    ) ReadError![]const u8 {        try self.capacity.validateReference(reference);        const expected = reference.extent.toUsize();        if (output.len < expected) return error.CallerBufferTooSmall;        const actual = try self.vtable.read(            self.context,            reference.identifier,            output[0..expected],        );        if (actual < reference.extent.bytes) return error.ContentTruncated;        if (actual > reference.extent.bytes) return error.ContentExtentMismatch;        const verified = output[0..expected];        if (!reference.identifier.matches(verified)) {            return error.ContentIdentifierMismatch;        }        return verified;    }};

Source: lib/content/src/root.zig:40

zig
pub const Reader = capability.Reader;
Called byCallsNo direct callersCapacityvalidateReferenceReaderread
Static calls · unresolved targets: 1 · external targets: 2.

Audit

Definitions3
Public names3
Members3
Version26.7.0
Revisiondaab053ee433