Repository navigation
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 afterdecode.- Decoders: var data getters return
Result<&[u8], DecodeError>/Result<&str, DecodeError>. Group accessors andend_offsetreturnResult. Group iteration yieldsResult<Entry, DecodeError>, and only fixed-stride groups are stillExactSizeIterator. - Sequential readers: group and var data accessors,
next_entry(Result<Option<_>, _>) andfinishreturnResult. Reading out of order returnsDecodeError::OutOfOrderinstead of panicking. - Encoders:
wrap,<group>_count,next_entry(Result<Option<_>, _>) andfinish(on messages with variable parts) returnResult<_, EncodeError>. Order and capacity are checked before anything is written. - Group and entry encoder
wrapis nowpub(crate).
- Decoders: var data getters return
- codegen: dropping a group encoder after writing fewer entries than declared now makes
finish()returnEncodeError::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_lengthreturnsResult<usize, DecodeError>. - core:
DecodeErroris now#[non_exhaustive], with new variantsVarPartOutOfBoundsandOutOfOrder. - core:
VarDataErroris renamedEncodeError(#[non_exhaustive]), andfieldnow names any part.VarDataErrorremains as a deprecated alias.
Added
- core: the
boundsmodule (span_end,group_header_at,var_data_at,var_data_end,ensure_capacity), plusReadBuffer::try_get_bytes,try_get_u8,try_get_u16_leandtry_get_u32_le. - core: version-aware block validation in
decode, viarequired_block_length,wrap_actingandDecodeError::BlockLengthTooSmall. Generated getters forsinceVersionfields returnOption, and group decoders reject a non-empty group whose entries are shorter than their fields. - ironsbe:
EncodeErroris re-exported at the crate root and in the prelude.
Testing
ironsbe-codegen-tests/tests/panic_free.rsdecodes 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 underdeny(clippy::panic, clippy::indexing_slicing, clippy::unwrap_used, clippy::expect_used).
Performance
sequential_decodep50: 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