fabruic icon indicating copy to clipboard operation
fabruic copied to clipboard

Add Customizable Serialization support through Transmog

Open ecton opened this issue 3 years ago • 1 comments

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 a format parameter. For compatibility with existing projects, add transmog-bincode as a dependency, and pass in transmog_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_format are new functions take a format parameter. This allows using a different serialization format on a per-stream basis, after the r#type phase. The existing functions call through to these new functions passing in the existing format used for r#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 support serialized_size currently.

ecton avatar Jan 05 '22 04:01 ecton

@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.

ecton avatar Jan 05 '22 14:01 ecton