ia0 / data-encoding

Efficient and customizable data-encoding functions in Rust
https://data-encoding.rs/
MIT License
177 stars 23 forks source link

Breaking change wish list #72

Open ia0 opened 1 year ago

ia0 commented 1 year ago

This issue lists breaking changes that could be worth doing. Since they would bump the major version, doing as much of them simultaneously would be best.

static instead of const

Using const prevents users to take long-term references, which is needed for Encoder. The constants should instead be statics.

const fn

This crate is mostly made of pure terminating functions (e.g. encode_len(), encode_mut(), decode_len(), and decode_mut()). Those functions should be const fn. This would replace the data-encoding-macro library which is currently working around the const fn limitations of Rust.

This is blocked by const fn support in Rust: meta tracking issue.

Private Encoding implementation

It should now be possible to make the Encoding implementation private and provide an unsafe const fn for data-encoding-macro to use.

MaybeUninit

Most output parameters are not read from but currently use &mut [u8] which requires them to be initialized. Those functions could instead take &mut [MaybeUninit<u8>].

This is mostly blocked by maybe_uninit_slice.

MSRV

Even if not necessary, bumping to the latest stable might give access to features that may be useful for future minor or patch versions. This is strictly speaking not a breaking change to bump MSRV (discussion), but it's nice to do it during a major bump. By discussion in #77 it would be nice to have the MSRV at rustc in Debian oldstable. This should cover most common distributions. Note also the trick to use syn = ">= 2, < 4" when multiple major versions are supported for a dependency.

Expose the polymorphic implementation

Currently only the type-erased API with internal dispatch is exposed. This may prevent dead-code elimination to trigger if encodings are not statically known, resulting in bigger binary size. As an alternative, the internal polymorphic API could be exposed.

This might be blocked by good const generics support in Rust.