fabruic
fabruic copied to clipboard
Add Customizable Serialization support through Transmog
This pull request brings in support for Transmog, allowing flexibility in configuring serialization formats. Closes #28.
This is currently a breaking change.
Connecting::acceptnow takes aformatparameter. For compatibility with existing projects, addtransmog-bincodeas a dependency, and pass intransmog_bincode::Bincode::default(). The positive side of this breaking change is that it puts the user in full control of their bincode serialization settings. The basic example diff shows the net effect of this breakage.Incoming::accept_with_format/Connection::open_stream_with_formatare new functions take aformatparameter. This allows using a different serialization format on a per-stream basis, after ther#typephase. The existing functions call through to these new functions passing in the existing format used forr#type.
Things left to do:
- [ ] Consider whether to keep this as a breaking change or to provide a convenience method that continues to use Bincode internally.
- [x] Update all affected methods' documentation.
- [x] Optimize sending when serialized_size returns none. Currently does an extra allocation that shouldn't be necessary by pre-padding the byte buffer, serializing, then filling in the length.
- [x] Add test using
Pot-- a format that doesn't supportserialized_sizecurrently.
@daxpedda This is ready to be looked at -- at least to the extent of answering the outstanding question on breaking the API. Currently this PR causes breaking changes, and I'm not sure what your thoughts are on requiring the user to specify the format themselves moving forward.
I'm going to create a CHANGELOG for Fabruic moving forward, but I wanted to wait to write it until we knew what we were doing with the breaking parts.