mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-11 04:52:13 +00:00
The crate denies panics, but asserts and slice indexing were reachable from arguments: pixel strides, buffers that are not whole pixels or a destination shorter than the source, single-colour slices shorter than the channel count, CLUT and pipeline dimensions, and LUT sizes. Every such check now returns CmsError::InvalidArgument. Buffer conversions validate once per call, before any pixel is written, so the per-pixel loops carry no extra checks; internal callers that already guarantee lengths use crate-private unchecked evaluation. Pipeline, Clut and Lut3d keep their fields private (read through accessors) so a validated value cannot be changed into one that panics. Pipeline::new checks matrix shapes and channel counts; Clut::new and Clut::sample check grid, outputs and the table size limit. API changes (unreleased crate): - Transform::eval, eval_fast, convert_u8/u16/f32, apply, convert_bytes_many and from_pipeline return Result. - Pipeline::new, extend and eval, Clut::new, sample, eval, eval_trilinear and eval_multilinear return Result. - GamutCheck::delta_e and out_of_gamut, Lut3d::from_transform, LutFile::identity and from_fn, synth::cmyk_profile and coated_cmyk return Result. - Pipeline, Clut and Lut3d fields are read through methods.