Skip to content

svga v0.1.0

Choose a tag to compare

@WendellXY WendellXY released this 19 Sep 04:53
· 4 commits to main since this release

First release of svga, a pure-Rust codec for the SVGA animation format: decode, inspect, edit without loss, encode. It renders nothing and makes no optimization decisions.

[dependencies]
svga = "0.1"

What is in it

  • Document, the lossless layer. Every top-level protobuf field is kept as its original bytes, so unknown fields, field order and float bit patterns survive, and an unedited document re-encodes to exactly the payload it was read from. replace_image, insert_image and remove_image return a new document and leave every other byte alone.
  • Movie, a typed read-only view decoded on demand: params, sprites, frames, layouts, transforms, shapes, audio. It reports referenced, unused and missing image keys, and the largest drawn size of each image across visible frames.
  • Animation, one entry point for every flavour: SVGA 2.x (zlib + protobuf), zipped 2.x (movie.binary) and SVGA 1.x (movie.spec JSON). to_document() turns the zip flavours into a standalone 2.x document.
  • Built for untrusted input. Configurable Limits (input size, inflated size, top-level fields, zip entries, 1.x spec size, decoded elements), trailing bytes after the zlib stream are an error, checked arithmetic throughout, and errors carry an ErrorKind plus a stable svga_* code.
  • Pure Rust by default, so it builds for wasm32 and on docs.rs. The optional libdeflate feature makes Compression::Best use libdeflate for the smallest output; the default zip feature can be turned off.

Verification

Checked against 233 real-world files (not part of the repository): all 231 zlib files re-encode to a byte-identical inflated payload, and every file's version, view box, fps, frame, image, sprite and audio counts match libsvga's svga_probe. The opt-in corpus test in tests/corpus.rs repeats this on any directory of files.

MSRV 1.89. MIT licensed.