Conversation
| let serialized_length = u64::try_from(serialized_length).expect("not a 64-bit system"); | ||
| bytes | ||
| .get_mut(0..8) | ||
| .expect("bytes never allocated") |
There was a problem hiding this comment.
I felt really stupid writing this code due to the clippy settings. With this chunk of code, it's crystal clear that this buffer can never be shorter than 8 bytes, yet I'm forced to use the non-panic versions and write expect instead of unwrap().
This code went from readable to a mess quickly, and I feel it's in part due to these clippy settings. I'm providing this as feedback for consideration -- not an edict that we should change the settings.
This commit adds support for specifying the serialization format at the time of accepting a connection, which means that ALPN protocol negotiation can be used to control which serialization format is used on an incoming connection. The next feature is the ability to switch serialization formats on a per-stream basis, after the r#type negotation.
|
@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. |
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:
Pot-- a format that doesn't supportserialized_sizecurrently.