Skip to content

Version 0.10.0

Compare
Choose a tag to compare
@csnover csnover released this 17 Sep 21:09
· 167 commits to master since this release
6679c0f

Breaking changes

  • The read_bytes helper, deprecated since 0.2.0, has been removed. Use Vec<u8> directly.

  • The NullString and NullWideString APIs have been rewritten to use only standard Rust traits:

    before 0.10 as of 0.10
    T::from_string(s) From<String> or From<&str>
    s.into_string() s.to_string() or Display trait
    s.into_string_lossless() TryFrom<T> for String trait
  • Two BinWrite API functions have been renamed for consistency with the BinRead API:

    before 0.10 as of 0.10
    BinWrite::write_to(...) BinWrite::write(...)
    BinWrite::write_with_args(...) BinWrite::write_args(...)
  • The HasMagic trait has been renamed to meta::ReadMagic.

  • The Endian::Native variant has been removed and replaced by an equivalent constant, Endian::NATIVE.

  • The Default implementation for Endian has been removed. Use an explicit value where needed instead.

  • Convenience functions that do not accept a byte order (e.g. BinRead::read(...), BinWrite::write(...)) are now only callable if the underlying type also implements meta::ReadEndian (for reads) and meta::WriteEndian (for writes). This prevents unintentional architecture-specific byte ordering. These new traits are automatically derived for types that specify a byte order and for built-in types that do not have any endianness (e.g. Vec<u8>).

New features

  • The BufReader wrapper significantly improves performance when reading from non-memory streams (#141)
  • The NoSeek wrapper enables reading and writing non-seekable streams (#6, #78)
  • Non-zero integer types are now supported by BinRead, BinWrite, and FilePtr (#134)
  • Added performance tips to the documentation (#130)

Enhancements

  • binread, binrw, and binwrite attributes are now also part of the binrw prelude
  • Improved performance reading integer primitives into collections (e.g. Vec<u32>) (#129)
  • The if directive is now also supported in #[bw] attributes (#113, #146)
  • Tuples can now use any args type that implements Clone
  • Error messages are now clearer when count and args are incorrectly combined, or when passing the wrong type to args (#112)
  • More impls have been added to the no_std implementations of the Read and Write traits to improve feature parity with the std implementations
  • The Debug implementations of NullString and NullWideString no longer allocate memory
  • Documentation has been generally improved (#75, #76, #103, #142)
  • Write support is now fully documented
  • Enum error handling modes are now documented
  • Explicit endian helper functions are now also available on BinRead and BinWrite

Bug fixes

  • Using try_map = {closure} on a struct now generates valid code
  • Errors in args directives now point to the correct location of the problem
  • The optimised impl BinWrite for Box<[u8]> is now actually selected by the compiler
  • Using named arguments no longer triggers clippy warnings about missing docs (#124)
  • Trailing commas no longer cause parsing errors in binrw::args!
  • NullString and WideNullString types are now correctly marked with Eq
  • Enum variants no longer sometimes unintentionally inherit directives from the parent enum
  • Deriving BinWrite on unit structs no longer causes a panic
  • pre_assert directives now correctly apply to unit enum values
  • Line numbers in verbose backtraces are now correctly padded when the number of digits in the line number increases