asset-io
Read, inspect and update media-file metadata through one Rust API.
asset-io gives image, audio, video and document formats a common model of
segments and metadata items. With it you can:
- Find and read XMP, JUMBF (including C2PA manifest stores), EXIF and embedded files.
- Replace or remove XMP and JUMBF without decoding or re-encoding media.
- Stream updates in one pass with bounded buffers, copying unchanged media.
- Hash while reading or writing, using a
Sinkthat sees every byte tagged. - Compute C2PA hash geometry (box lists and data-hash exclusions), even before writing.
- Add formats by registering your own handlers at runtime.
The core is runtime-independent and supports blocking, Tokio and caller-driven I/O. Used by c2pa-rs, it handles container structure and metadata placement, not manifest interpretation, hashing or signing.
Installation
Enable the formats you need. No formats are enabled by default.
[]
= { = "0.3", = ["jpeg", "png"] }
Requires Rust 1.88 or later.
Usage
Read metadata and write an updated copy:
use ;
use ;
The input is never modified. Content detection takes precedence over the
optional format argument; pass an extension or MIME type, such as Some("svg"),
for formats without a signature.
The main types:
Asset: a parsed file with its blocking stream. Start here.Structure: segments, items and byte ranges, without owning the bytes. Use it for async I/O, write planning and hash geometry.Updates: XMP and JUMBF changes.writereturns the output's structure;plancomputes it without writing.HandlerRegistry: built-in and custom handlers. Libraries should accept a registry and callAsset::open_with, so their callers control format support.
The user guide covers the model, C2PA support, embedded files and custom I/O in depth.
Supported formats
Each feature enables one built-in handler that reads and updates metadata.
all-formats enables all of them.
| Feature | Formats | C2PA hash | Notes |
|---|---|---|---|
jpeg |
JPEG, MPO | Box | Multi-Picture Format and Ultra HDR images; JPEG XT JUMBF |
png |
PNG | Box | |
bmff |
MP4, MOV, M4A, M4V, HEIF, HEIC, AVIF | BMFF | Rewrites chunk offsets; merkle boxes |
riff |
WebP, WAV, AVI | Box | |
tiff |
TIFF, BigTIFF, DNG; ARW and NEF read-only | Data | Append-only IFD updates |
gif |
GIF | Box | Application extensions |
id3 |
MP3, FLAC | Data | Leading ID3v2.3/2.4 tag |
svg |
SVG | Data | Splices metadata without re-serializing |
pdf |
PDF 1.0–2.0 | — | Incremental updates |
c2pa |
C2PA sidecars (.c2pa) |
— | Whole-file manifest store |
Optional features:
| Feature | Adds |
|---|---|
tokio |
Tokio adapters for async parsing, reads and writes |
xmp |
MiniXmp for minimal XMP reading and modification |
exif |
Basic EXIF fields and EXIF JPEG thumbnails |
flate |
zlib, deflate and gzip decoding for stored content; enabled by pdf |
brotli |
Brotli decoding for stored content |
memory-mapped |
MappedFile for zero-copy reads |
all-formats does not enable the optional features.
Examples
# Print a file's structure and items.
# Inspect or edit files concurrently with Tokio, hashing output as it is written.
Documentation
- API documentation
- User guide: the model, updates, C2PA, embedded files and I/O
- Container handler guide: writing, testing and adding format handlers
- C bindings for C, C++, Python and Swift, built from this repository
- Release notes
Contributions and feedback
We welcome contributions to this project. For information on contributing, providing feedback, and about ongoing work, see Contributing.
License
Licensed under either of MIT or Apache-2.0, at your option.