-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add serde-style brw(with)
attribute
#98
Labels
enhancement
New feature or request
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
General idea is providing a module containing both a custom parser and a custom writer function. This would also make it easier to make binrw compatibility crates by allowing you to two generic functions that are custom readers/writers for all types the crate supports to get around orphan rules:
In the compatibility crate (let's call it
binrw_3d
, similar to bevy-style 3rd party compatibility crates, basically a binrw crate with common 3d type parsers):Then for each type that should be supported, make a new struct implement
BinRead
/BinWrite
as normal, and implement conversion to and from the type itself. Then all that's needed is:And while that's a bit of boilerplate just to make a binrw implementation for a foreign type, all that your crate user needs to do is:
and the foreign types "just work"
Open Design Questions
Should binrw provide a macro or two to make all the boilerplate above just a single line? Is encouraging 3rd-party utility types worthwhile enough for that? Maybe something like:
The text was updated successfully, but these errors were encountered: