mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 09:46:59 -06:00
Raster::new checked its RGBA length with assert_eq!, so bytes of the wrong length (from a file, a plug-in or a control message) would abort instead of reporting an error. It now returns Result<Raster, TraceError> and gives TraceError::Decode naming the byte count and the size (the existing variant, whose text is already translated, instead of a new message every language would need). The size product is checked for overflow. Raster::pixel indexed the bytes directly; it now gives transparent black outside the raster, or past the end of a raster whose public fields were set to a size its bytes don't have (which mosaic reads). The public signature changes: every caller in the workspace was a test (trace unit tests, Flat Logo tests and the quality harness), updated to unwrap. No shipped code built a Raster with new; decode, decode_to_fit and from_fn always make the right length, and trace_within already refuses a raster whose fields disagree. Test (code-drawn): a_raster_of_the_wrong_length_is_an_error_not_a_crash (short, long, empty, zero-width and overflowing sizes; pixel, trace and mosaic on a raster whose fields disagree). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018tBcdwNhptqtmX32JCGFzB