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
- Content
Inputs - 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. - Content
Limits - 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.
- Content
Meta - What a document records about content instead of its bytes, so placeholders reserve the eventual dimensions before those bytes arrive.
- Content
Ref - A parsed reference: the address content is stored under, and the key sealed content opens with.
- Content
Store - 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. - Document
Format - A document format, named by its file extension and media type, with what a person calls it.
- Files
Backend - Content stored one file per address in a
Location, throughtilo-files’ synchronous operations (in a page, the profile’s mirror of its app files, written through to the origin-private file system). - Image
Format - A picture format, named by its file extension and media type.
- Media
Facts - What a file’s header says about it.
- Memory
Backend - 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 aContentReader. - Workspace
Stores - Each workspace’s content store under one directory, by the workspace’s id.
Enums§
- Content
Error - Why a store refused a write or could not complete a read or collection.
- Content
State - 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
factsreads 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§
- Content
Backend - What a
ContentStoreruns 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. - Content
Source - 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
referencenames its content by, as stored and carried (lower case): what a host keeps, serves and asks for.Nonefor no reference. - document_
format - The document format
byteshold: a recording by its header, a PDF by its%PDF-header, an Office orOpenDocumentpackage by the parts and media type its zip holds, RTF, or an HTML page.Nonefor plain text, Markdown and anything else, whose name is all that says what it is. - facts
- The facts the file called
namestates inbytes, its firstFACTS_SCAN_BYTES(and, for a recording, possibly its last as many after them).Nonewhen its name and its bytes disagree or its header states nothing. - has_
facts - Whether
factscan find anything in a file calledname, so a caller can skip reading it. - hash_
bytes - Hash
bytesthe way every content address in the system is derived: BLAKE3, lower-case hex. - image_
format - The picture format
bytesstart with, from the signature alone: PNG, JPEG, GIF, WebP or SVG. Unlikesniffit 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
viewBoxdraws in.Nonewhenbytesis no such picture or its header states no size. - is_
sealed - names
- Whether
bytesare the contentreferencenames: 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”.
Nonewhen the bytes say nothing (plain text, or a format not known here). - part_
key - The key
bytesare sealed under by whoever holds the members’ contentsecret: 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
lenand reserves no particular size. - valid_
hash - Whether
hashhas 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
bytesreally are the content named byhash.
Type Aliases§
- Content
Reader - A streaming read of stored content. It fails with
std::io::ErrorKind::InvalidDataat the end if the bytes turn out not to match their address, so a consumer that reads to the end has read verified content.