Skip to main content

Crate rust_motion_affinity

Crate rust_motion_affinity 

Source
Expand description

Reader for native Affinity documents (.af, and .afdesign/.afphoto/.afpub from Affinity 1 and 2): the archive container, the tagged object stream in doc.dat, and the subset of the document model PhotoCraft imports.

Layouts follow the MIT-licensed afread reference and were checked against public documents saved by Affinity 1.x to 3.x (container versions 8 to 12); see the crate README for provenance and the exact supported subset. Nothing here writes Affinity files.

Re-exports§

pub use container::is_affinity;
pub use container::Archive;
pub use container::Limits;
pub use container::MAGIC;
pub use model::read;
pub use model::Document;
pub use preview::preview;
pub use preview::Preview;
pub use preview::MAX_PREVIEW_BYTES;
pub use preview::MAX_PREVIEW_DIMENSION;

Modules§

container
The Affinity archive: header, the chain of file allocation tables (one per save) and bounded, CRC-checked extraction of named entries such as doc.dat and raster tiles.
model
The document model PhotoCraft imports: spreads, artboards, layers, groups, curves, shapes, text and images, with transforms composed into document space. Anything else is reported by Document::warnings instead of being dropped silently.
paint
Fills, strokes and colours. Two schemas exist: Affinity 1 (BFil fill, PFil stroke paint, LSty stroke style) and Affinity 2/3 (BFFl, LIFl and LILn lists with a current index).
preview
The indexed PNG thumbnail Affinity stores next to the archive: Affinity’s own render of the document, at most 512 pixels on the long side in real files, never the document itself.
stream
The tagged object stream inside doc.dat: a self-describing tree of objects whose fields carry a type code and a four-character tag. Parsing needs no schema; unknown fields are kept, so the document mapping can name what it could not import.

Enums§

Error
Why a file could not be read. Messages are short reasons; callers add advice.