Skip to content

v0.8.0

Latest

Choose a tag to compare

@joaquinbejar joaquinbejar released this 25 Oct 05:36
· 2 commits to main since this release

Breaking changes

  • codegen: generated codecs no longer panic on untrusted input or short buffers (#74, #76). Every operation that can fail now returns a Result. Fixed-field getters stay infallible after decode.
    • Decoders: var data getters return Result<&[u8], DecodeError> / Result<&str, DecodeError>. Group accessors and end_offset return Result. Group iteration yields Result<Entry, DecodeError>, and only fixed-stride groups are still ExactSizeIterator.
    • Sequential readers: group and var data accessors, next_entry (Result<Option<_>, _>) and finish return Result. Reading out of order returns DecodeError::OutOfOrder instead of panicking.
    • Encoders: wrap, <group>_count, next_entry (Result<Option<_>, _>) and finish (on messages with variable parts) return Result<_, EncodeError>. Order and capacity are checked before anything is written.
    • Group and entry encoder wrap is now pub(crate).
  • codegen: dropping a group encoder after writing fewer entries than declared now makes finish() return EncodeError::BufferTooShort. Before, it silently produced a frame that announced the missing entries. The same applies when an entry encoder can't fit its trailing empty headers, or a reader's drop can't walk the parts that weren't read.
  • core: SbeDecoder::encoded_length returns Result<usize, DecodeError>.
  • core: DecodeError is now #[non_exhaustive], with new variants VarPartOutOfBounds and OutOfOrder.
  • core: VarDataError is renamed EncodeError (#[non_exhaustive]), and field now names any part. VarDataError remains as a deprecated alias.

Added

  • core: the bounds module (span_end, group_header_at, var_data_at, var_data_end, ensure_capacity), plus ReadBuffer::try_get_bytes, try_get_u8, try_get_u16_le and try_get_u32_le.
  • core: version-aware block validation in decode, via required_block_length, wrap_acting and DecodeError::BlockLengthTooSmall. Generated getters for sinceVersion fields return Option, and group decoders reject a non-empty group whose entries are shorter than their fields.
  • ironsbe: EncodeError is re-exported at the crate root and in the prelude.

Testing

  • ironsbe-codegen-tests/tests/panic_free.rs decodes every truncated prefix of every test message, applies 10k deterministic byte mutations per message, and encodes into every buffer size. The panic-free module is built under deny(clippy::panic, clippy::indexing_slicing, clippy::unwrap_used, clippy::expect_used).

Performance

  • sequential_decode p50: the sequential path is the same or faster (256 levels: 375 to 292 ns). Random access is about 40 ns slower at 16 levels and about 25% slower at 64 levels, and faster at 256 levels (2459 to 2083 ns).

Full changelog: v0.7.2...v0.8.0