Releases: smessmer/binary-layout
4.0.2
4.0.1
4.0.0
This release adds supports for types that can throw errors when reading or writing.
New primitive types supported:
std::num::NonZeroXXX
typesbool as u8
(only0
and1
are valid representations, others will throw errors when read)char as u32
(invalid unicode will throw errors when read)
When reading any of those types, the read()
function will not be available and instead there will be a try_read()
function.
The LayoutAs
trait changed and if you're using that to define custom data types, then you now need to implement try_read
/ try_write
instead of read
/ write
.
If reading and/or writing your type cannot fail, you can set the corresponding error type to std::convert::Infallible
.
That will ensure that your type will have the read() / write()
functions available on your layout fields.
For any other error types, you will have to access the fields using calls to try_read() / try_write()
.
Backwards compatibility:
Most code should remain backwards compatible, but there are a few scenarios that require you to change your code:
- Updated MSRV to 1.59
- If you did not use
use binary_layout::prelude::*
but instead imported thebinary_layout
traits manually, then you may have to add an import to
FieldReadExt
andFieldWriteExt
because that is where theread()
andwrite()
methods that were previously onFieldCopyAccess
moved to. - Types implementing
LayoutAs
now need to beSized
. - The
LayoutAs
trait changed. You now need to implementtry_read
andtry_write
instead ofread
andwrite
and define the corresponding error types. - Renamed
define_layout!
macro tobinary_layout!
. For now,define_layout!
still works but will show a deprecation warning and it will be removed in a future version.