Version 0.15.2
- binrw is now future-compatible with pub_use_of_private_extern_crate. (https://github.com/jam1garner/binrw/pull/361. Thanks, @jakobhellermann!)
Version 0.15.0
- The generic parameter lists for
binrw::helpersfunctions have been reordered to put most-frequently-used parameters first. - Lifetime parameters have been added to several
binrw::helpersfunctions to support borrowed arguments. - The MSRV has been increased to 1.70.
- Parsing a unit enum with
magicwill now return anIo(UnexpectedEof)error when all attempts to read magic result in anUnexpectedEof. Previously, this would returnNoVariantMatch. (#324, #325. Thanks, @plaflamme!)
PosValuenow includes implementations forDefaultandBinWrite. TheBinWriteimplementation simply treatsPosValueas a wrapper and writes the stored value in place; theposfield is ignored. Use theseek_beforeand (optionally)restore_positiondirectives if you want to write aPosValuevalue to a different position in the output stream. (#270, #273. Thanks, @amirbou!)- binrw now uses syn 2 internally, which should reduce the build time for most users of binrw when used with other dependencies that have also updated to syn 2. (#285, #299. Thanks, @Urist-McGit!)
- The amount of code generated has been reduced, improving compilation times. (#319. Thanks, @ScanMountGoat!)
- Various small documentation improvements. (Thanks, @marxin!)
BinWrite::write_neandBinWrite::write_ne_argsconvenience functions have been added to match the same functions in theBinReadAPI.- The owo-colors dependency has been updated to version 4.
- Using
SeekFrom::EndwithTakeSeeknow correctly seeks relative to the end of the stream if the stream is shorter than the limit. (#291) - Using
binrw::helpers::count_withto return aVec<{integer}>using a custom function will no longer ignore the custom function. (#318. Thanks, @kitlith!) - It is now possible to pass borrowed values when using
binrw::helpersfunctions. - The
argsdirective can now be used when closures are passed toparse_withorwrite_with. - All forwarding calls in the
BinReadExtandBinWriteExttraits are now appropriately annotated with#[inline].
Version 0.14.0
- In derived
BinWriteimplementations, imported variables are now exposed before field variables, to match the way lexical scoping normally works. If an import and a field have the same name, this will cause the import to be shadowed. Previously, the field would be shadowed.
- Diagnostic output is improved when using
parse_withandmaptogether in an incompatible way.
- It is now possible to use a mix of generic and concrete types in
BinWritederives without triggering a type mismatch error. - It is now possible to use the anonymous lifetime
'_within nested types inside animportdirective. (#241) - The compiler will no longer panic when
verbose-backtraceis enabled and a derived type contains a docblock with a completely empty line. (#263) - Generated code will no longer trigger
clippy::unnecessary_fallible_conversionslints.
Version 0.13.0
- The stream specified by
map_streamis now only used when reading the inner value(s) of the field/struct/enum it is applied to. Previously, the mapped stream would also be used for magic, padding, etc. when those directives were also applied to the same field or type, but this caused problems with re-borrowing the stream and made the scope of the directive confusing.
- Helper functions for reading and writing unsigned 24-bit integers have been added.
- It is now possible to use
map_streamwithcountwithout causing a borrowck error. - It is now possible to pass args to a
parse_withfunction that is notCopywithout causing a borrowck error. (#185) - It is now possible to derive
BinWriteon a type whose associatedArgstype implementsDefaultbut is not the unit type. (Thanks, @octylFractal!) - It is now possible to use
PhantomData<T>withBinWritewhereTis notBinWrite. (Thanks, @DCNick3! #230) - Calling
custom_erron an error with a backtrace will now correctly return the original custom error. (#228) - Rust compiler and dependency versions have been updated to the correct minimum versions. (#224)
- Calling
Error::custom_errwill now always return the custom error even if there is a backtrace associated with it. (#228) - Using
selfin top-level#[bw]directives now works as expected. (#232) #[bw(assert)]now actually emits assertions on enums and data enum variants instead of silently accepting the directive without emitting any code.
Version 0.12.0
- The default behaviour of
FilePtrhas been changed to always immediately seek to and read the pointed-to value. Helper functions have been added to thefile_ptrmodule to support the common case of reading from an offset table. Additional helper functions and types will be added in future releases to improve support for file indirection. - The
BinRead::after_parseAPI has been removed since it was rarely used, usually broken by manualBinReadimplementations, and made it impossible to use borrowed values in arguments in some cases. For custom two-pass parsing, one alternative is to create an object that will store data that need to be used during the second pass, pass a mutable reference to that object as an argument toread_options, add data to that object during the first pass, then use the recorded data from the object to perform the required action for the second pass. deref_now,offset_after, andpostprocess_nowhave been removed as they were designed to control theafter_parseAPI which no longer exists. Any field with aderef_noworpostprocess_nowdirective can simply remove the directive to achieve equivalent functionality. Any struct that usedoffset_aftershould reorder the fields so the dependent field is after the offset location.
For more detail on these changes, see #210.
- Selected helper functions are no longer re-exported to the root of the crate. Access these helper functions, plus all the other helper functions that were never re-exported to the root, from the
helpersmodule. - Using the undocumented internal variable
thisfrom anassertdirective is no longer supported. Replacethiswith the supportedselfkeyword instead.
- Helper functions for more efficient reading of offset tables have been added to the
file_ptrmodule. These helpers can be combined with theseek_beforedirective to support both relative and absolute positioning of the pointed-to data. See the documentation for usage information and examples. assertdirectives on structs, non-unit enums, and data variants can now access the constructed object using theselfkeyword. (Thanks, @octylFractal!) (#219)
Cloneis no longer a required trait for arguments passed toparse_withfunctions. (Thanks, @octylFractal!)Cloneis no longer a required trait for arguments passed toBinReaderExtmethods.BinReadis no longer a required trait for dereferencing a value fromFilePtr. (#218)mapandtry_mapfunctions can now mutably borrow values.dbgnow also prints information about any padding and alignment directives on a field.- Various documentation improvements.
- The
countdirective no longer attempts useless conversions. (Thanks, @poliorcetics!) (#206) dbgnow returns the correct position of a field when usingpad_beforeoralign_before. (#188)- Parser errors are no longer discarded if a stream rewind fails. (#215)
- Implementation details of binrw will no longer cause borrow checker failures when passing borrowed arguments to child objects.