Skip to main content

Module assets

Module assets 

Source
Expand description

Artwork at the container boundary: assets/<hash>.<ext> is the one home for bytes, and everything else keeps only the hash.

Content addressing is load-bearing rather than an optimization. A rev file is the whole document, so a 1.5 MB symbol written into it would be written again into every rev that stands after it — and the same file is git-diffed and read on every open. Content addressing means the bytes land once, are never rewritten, and are never deleted: reclaiming what nothing references belongs to compaction, not to an edit.

crates/doc knows nothing about any of this. A document is stripped on its way into a rev file and re-attached on its way out (Document::without_assets), so the document crate only ever sees payloads with their bytes in hand.

Structs§

AssetFault
A reference a document makes and the store cannot honour.
Held
Payloads that die with the process — a session with no container, and what a test stands a rev store on.

Enums§

AssetFormat
How to read a payload’s bytes — which is also its file extension. Not derived from the [Asset] variant name: the durable spelling is lowercase because it is a file suffix.
Miss
Why a payload could not be handed back.

Traits§

AssetSink
Where payloads are written. Separate from AssetSource because a read-only session has one and not the other.
AssetSource
Where payloads are read back from. A trait rather than a directory because a session with no files reads its own, and the browser reads the same names out of origin storage.

Functions§

hydrate
Read hash’s payload back and check it against the hash that named it.