lib/content/src/root.zig
daab053ee43316e1809a84551d573ddd1e5bf3d2
1 //! Content-addressed storage for immutable bytes names a piece of content by
2 //! what it hashes to. The authority to read, a *Reader*, and the authority to
3 //! write, a *Sink*, are separate values, so a caller can hold one without the
4 //! other, while pairing the two for a caller trusted with both forms a *Store*.
5 //!
6 //! The caller supplies the limits, and every store is built against a
7 //! *capacity* derived from them, which fixes how many objects it admits, how
8 //! large one object may be, and how many bytes it retains. One content
9 //! identifier (a hash algorithm tag and a 32-byte digest) paired with the exact
10 //! byte length of the content forms a *reference*. Each capability reaches the
11 //! backend behind it through an opaque context pointer and a function table,
12 //! its *provider*. Both capabilities check a reference against that capacity
13 //! before the provider is called at all. A capability checks what its provider
14 //! returns: a read rehashes the bytes and compares the length before it hands
15 //! them back, while a publication verifies the bytes against the reference
16 //! first.
17 //!
18 //! Listing, deleting, and naming content by path are absent from both
19 //! capabilities, so holding one grants exactly one operation. The `memory`
20 //! namespace holds the in-memory provider, which works entirely from
21 //! caller-owned buffers.
22
23 const capability = @import("capability.zig");
24 const model = @import("model.zig");
25
26 pub const Algorithm = model.Algorithm;
27 pub const Capacity = model.Capacity;
28 pub const CapacityError = model.CapacityError;
29 pub const Extent = model.Extent;
30 pub const Identifier = model.Identifier;
31 pub const Limits = model.Limits;
32 pub const Reference = model.Reference;
33 pub const ReferenceError = model.ReferenceError;
34 pub const metadata_entry_bytes = model.metadata_entry_bytes;
35 pub const maximum_extent_bytes = model.maximum_extent_bytes;
36
37 pub const Publication = capability.Publication;
38 pub const PublicationError = capability.PublicationError;
39 pub const ReadError = capability.ReadError;
40 pub const Reader = capability.Reader;
41 pub const Sink = capability.Sink;
42 pub const Store = capability.Store;
43
44 pub const memory = @import("memory/root.zig");