Version 0.10.0
Breaking changes
-
The
read_bytes
helper, deprecated since 0.2.0, has been removed. UseVec<u8>
directly. -
The
NullString
andNullWideString
APIs have been rewritten to use only standard Rust traits:before 0.10 as of 0.10 T::from_string(s)
From<String>
orFrom<&str>
s.into_string()
s.to_string()
orDisplay
traits.into_string_lossless()
TryFrom<T> for String
trait -
Two
BinWrite
API functions have been renamed for consistency with theBinRead
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 tometa::ReadMagic
. -
The
Endian::Native
variant has been removed and replaced by an equivalent constant,Endian::NATIVE
. -
The
Default
implementation forEndian
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 implementsmeta::ReadEndian
(for reads) andmeta::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
, andFilePtr
(#134) - Added performance tips to the documentation (#130)
Enhancements
binread
,binrw
, andbinwrite
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
andargs
are incorrectly combined, or when passing the wrong type toargs
(#112) - More impls have been added to the
no_std
implementations of theRead
andWrite
traits to improve feature parity with thestd
implementations - The
Debug
implementations ofNullString
andNullWideString
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
andBinWrite
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
andWideNullString
types are now correctly marked withEq
- 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