base64-serde
base64-serde copied to clipboard
Use heap-free `Base64Display`
As per the commented out code in https://github.com/serde-rs/json/issues/360#issuecomment-330095360, we could use serializer.collect_str with the Display wrapper. However, that wrapper can only work with suitable configs (line wrap with length that is a multiple of 4 and not a crazy long line length). In practice, all configs that people are likely to use will satisfy this: MIME is the only common one that wraps, and it uses lines of 76 chars.
Options (not exhaustive):
- Just
expect("Programmer error: should've used a valid config")and hope for the best - Enhance the
ChunkedEncoderimplementation used by theDisplaywrapper to allow anyConfig - Define a
ChunkedEncoderConfigthat can only be constructed from aConfigthat is suitable, which we could then use to enforce via the type system that these things are only constructed in a valid way
@dtolnay thoughts?