jam1garner/binrw
 Watch   
 Star   
 Fork   
2026-07-23 14:49:45
binrw

Version 0.15.2

Bug fixes

2026-03-04 08:11:18
binrw

Version 0.15.1

Changes

  • The rarely-used variadic signature for #[binrw::parser] and #[binrw::writer] helper functions now requires a field name (i.e. fn foo(...) must now be fn foo(_: ...) so that the Rust compiler team can do good things. (#342)
2025-05-06 05:43:43
binrw

Version 0.15.0

Breaking changes

  • The generic parameter lists for binrw::helpers functions have been reordered to put most-frequently-used parameters first.
  • Lifetime parameters have been added to several binrw::helpers functions to support borrowed arguments.
  • The MSRV has been increased to 1.70.
  • Parsing a unit enum with magic will now return an Io(UnexpectedEof) error when all attempts to read magic result in an UnexpectedEof. Previously, this would return NoVariantMatch. (#324, #325. Thanks, @plaflamme!)

Enhancements

  • PosValue now includes implementations for Default and BinWrite. The BinWrite implementation simply treats PosValue as a wrapper and writes the stored value in place; the pos field is ignored. Use the seek_before and (optionally) restore_position directives if you want to write a PosValue value 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_ne and BinWrite::write_ne_args convenience functions have been added to match the same functions in the BinRead API.
  • The owo-colors dependency has been updated to version 4.

Bug fixes

  • Using SeekFrom::End with TakeSeek now correctly seeks relative to the end of the stream if the stream is shorter than the limit. (#291)
  • Using binrw::helpers::count_with to return a Vec<{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::helpers functions.
  • The args directive can now be used when closures are passed to parse_with or write_with.
  • All forwarding calls in the BinReadExt and BinWriteExt traits are now appropriately annotated with #[inline].
2024-10-14 03:20:47
binrw

Version 0.14.1

Bug fixes

  • Passing a SeekFrom::End to TakeSeek::seek now correctly seeks from the end of the TakeSeek stream instead of the end of the inner stream. (#291)
2024-06-07 12:21:13
binrw

Version 0.14.0

Breaking changes

  • In derived BinWrite implementations, 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.

Enhancements

  • Diagnostic output is improved when using parse_with and map together in an incompatible way.

Bug fixes

  • It is now possible to use a mix of generic and concrete types in BinWrite derives without triggering a type mismatch error.
  • It is now possible to use the anonymous lifetime '_ within nested types inside an import directive. (#241)
  • The compiler will no longer panic when verbose-backtrace is enabled and a derived type contains a docblock with a completely empty line. (#263)
  • Generated code will no longer trigger clippy::unnecessary_fallible_conversions lints.
2023-11-29 12:46:54
binrw

Version 0.13.3

Bug fixes

  • Using parse_with/write_with, map_stream, and args together will no longer raise an error about incompatible stream types. (#240)
2023-11-26 15:19:49
binrw

Version 0.13.2

Bug fixes

Using parse_with with map/try_map will no longer raise an error about incompatible types when the types are actually compatible. (#239)

2023-11-06 02:09:32
binrw

Version 0.13.1

Bug fixes

  • Using stream directive together with map_stream no longer causes a borrowck error. (#236)
2023-10-27 11:27:21
binrw

Version 0.13.0

Breaking changes

  • The stream specified by map_stream is 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.

New features

  • Helper functions for reading and writing unsigned 24-bit integers have been added.

Bug fixes

  • It is now possible to use map_stream with count without causing a borrowck error.
  • It is now possible to pass args to a parse_with function that is not Copy without causing a borrowck error. (#185)
  • It is now possible to derive BinWrite on a type whose associated Args type implements Default but is not the unit type. (Thanks, @octylFractal!)
  • It is now possible to use PhantomData<T> with BinWrite where T is not BinWrite. (Thanks, @DCNick3! #230)
  • Calling custom_err on 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_err will now always return the custom error even if there is a backtrace associated with it. (#228)
  • Using self in 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.
2023-09-22 05:28:38
binrw

Version 0.12.0

Breaking changes

  • The default behaviour of FilePtr has been changed to always immediately seek to and read the pointed-to value. Helper functions have been added to the file_ptr module 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_parse API has been removed since it was rarely used, usually broken by manual BinRead implementations, 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 to read_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, and postprocess_now have been removed as they were designed to control the after_parse API which no longer exists. Any field with a deref_now or postprocess_now directive can simply remove the directive to achieve equivalent functionality. Any struct that used offset_after should 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 helpers module.
  • Using the undocumented internal variable this from an assert directive is no longer supported. Replace this with the supported self keyword instead.

New features

  • Helper functions for more efficient reading of offset tables have been added to the file_ptr module. These helpers can be combined with the seek_before directive to support both relative and absolute positioning of the pointed-to data. See the documentation for usage information and examples.
  • assert directives on structs, non-unit enums, and data variants can now access the constructed object using the self keyword. (Thanks, @octylFractal!) (#219)

Enhancements

  • Clone is no longer a required trait for arguments passed to parse_with functions. (Thanks, @octylFractal!)
  • Clone is no longer a required trait for arguments passed to BinReaderExt methods.
  • BinRead is no longer a required trait for dereferencing a value from FilePtr. (#218)
  • map and try_map functions can now mutably borrow values.
  • dbg now also prints information about any padding and alignment directives on a field.
  • Various documentation improvements.

Bug fixes

  • The count directive no longer attempts useless conversions. (Thanks, @poliorcetics!) (#206)
  • dbg now returns the correct position of a field when using pad_before or align_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.