Skip to main content

Crate tilo_content

Crate tilo_content 

Source
Expand description

tilo-content — binary content by address.

Apps keep their data as versioned resources: a log of the actions performed on them, replayed into state. That is the default. Some bytes are not a resource, though: the photograph a photo library was imported from, an image placed in a document, a mail attachment. Those are binary inputs. A resource refers to one by its content hash, and the bytes live here, once, however many documents and versions refer to them.

Structs§

Collected
ContentInputs
Binary inputs found by pure code — the images an importer met — keyed by address, for the caller to persist (ContentStore::put_inputs) before the document naming them is kept.
ContentLimits
Hard limits for a store. They cover both payload and metadata: a document that names millions of tiny items must not be able to turn a bounded byte budget into an unbounded index.
ContentMeta
What a document records about content instead of its bytes, so placeholders reserve the eventual dimensions before those bytes arrive.
ContentRef
A parsed reference: the address content is stored under, and the key sealed content opens with.
ContentStore
An app’s handle to binary content: cheap to clone, passed to whatever needs it.
DirBackend
Content in <root>/<hash[..2]>/<hash>. Writes stream into a temporary file beside the target and are renamed into place once complete and hashed, so a reader never sees a partial item under an address that promises whole content; reads verify as they stream.
DocumentFormat
A document format, named by its file extension and media type, with what a person calls it.
FilesBackend
Content stored one file per address in a Location, through tilo-files’ synchronous operations (in a page, the profile’s mirror of its app files, written through to the origin-private file system).
ImageFormat
A picture format, named by its file extension and media type.
MediaFacts
What a file’s header says about it.
MemoryBackend
NoContent
Stored
Verifying
A reader that hashes what passes through and fails at the end if it was not expected: what a backend wraps a read from storage it does not trust in, so it returns a ContentReader.
WorkspaceStores
Each workspace’s content store under one directory, by the workspace’s id.

Enums§

ContentError
Why a store refused a write or could not complete a read or collection.
ContentState
Where the content behind an address has got to.

Constants§

BLOB_SCHEME
The scheme of the address a file’s content reads at, tilo-blob://<hash>: what a record names its files by, beside the bytes a content store keeps.
FACTS_SCAN_BYTES
How many of a file’s first bytes facts reads at most; a reader that holds more passes this many from the start, and may add as many from the end, where a recording often keeps its index.
PART_BYTES
The most bytes one part holds: far below what one item may be anywhere.
RECORDING
A recording (RECORDING_MAGIC).
RECORDING_MAGIC
The first bytes of a recording: a stretch of a resource’s history as a document of its own, which the app it recorded opens to replay it.
SHARED_STORE_ENV
The environment variable naming a content directory shared by every app of one session (the shell sets it for the apps it hosts), so content one app stores another can open.

Traits§

ContentBackend
What a ContentStore runs on. Implementations treat the address as authoritative and verify content against it; a store that trusts the key would let one peer poison every replica that later reads that address.
ContentSource
Read access to content by address, for code that turns documents into something else (an exporter embedding images, a renderer) without doing I/O of its own.

Functions§

content_address
The address reference names its content by, as stored and carried (lower case): what a host keeps, serves and asks for. None for no reference.
document_format
The document format bytes hold: a recording by its header, a PDF by its %PDF- header, an Office or OpenDocument package by the parts and media type its zip holds, RTF, or an HTML page. None for plain text, Markdown and anything else, whose name is all that says what it is.
facts
The facts the file called name states in bytes, its first FACTS_SCAN_BYTES (and, for a recording, possibly its last as many after them). None when its name and its bytes disagree or its header states nothing.
has_facts
Whether facts can find anything in a file called name, so a caller can skip reading it.
hash_bytes
Hash bytes the way every content address in the system is derived: BLAKE3, lower-case hex.
image_format
The picture format bytes start with, from the signature alone: PNG, JPEG, GIF, WebP or SVG. Unlike sniff it needs no complete header, so it also answers for a truncated prefix.
image_size
A picture’s format and intrinsic width and height, read from its header: PNG, JPEG, GIF and WebP from their container headers, SVG from the size its root element states or the box its viewBox draws in. None when bytes is no such picture or its header states no size.
is_sealed
names
Whether bytes are the content reference names: the bytes its address hashes, or for a sealed reference the bytes whose sealing under its key that address hashes.
opened_as
The file extension and media type content is taken as, from its bytes: a picture or video by signature, a document by format, text as text, anything else opaque. Content travels without the name its sender gave it, so the bytes alone say which app’s file it is.
opened_by
What an agent is told of content an action does not open: what it is and what opens it, “this is a Word document; use word-processor open-document”. None when the bytes say nothing (plain text, or a format not known here).
part_key
The key bytes are sealed under by whoever holds the members’ content secret: the same bytes take the same key, so they are one item under one reference however often they are kept (ContentBackend::content_secret).
sniff
Derive a descriptor from content: media type plus intrinsic dimensions, read from the container header rather than a full decode (the point is only to know how much space to reserve). An unrecognised format still gets a correct len and reserves no particular size.
valid_hash
Whether hash has the shape of a content address: 64 lower- or upper-case hex digits. Addresses arrive from documents and peers, so anything else is refused before it can name a path.
valid_reference
verify
True when bytes really are the content named by hash.

Type Aliases§

ContentReader
A streaming read of stored content. It fails with std::io::ErrorKind::InvalidData at the end if the bytes turn out not to match their address, so a consumer that reads to the end has read verified content.