Skip to content

No good alternative to decode_config() in 0.20 #205

Closed
@djc

Description

@djc

I'm unhappy about the API changes in 0.20. In my code base at work we have 12 use cases of base64 0.13 encoding and decoding, 9 of which pass a config (mostly URL_SAFE_NO_PAD, some URL_SAFE). Unless I misunderstand the new API (I don't see any examples of this use case in the README or the top-level documentation), in order to obtain the same result with 0.20 I would have to instantiate a custom FastPortable (which, despite being the only engine shipped with 0.20, I have to import from base64::engine::fast_portable::FastPortable) and initialize with base64::alphabet::URL_SAFE and base64::engine::fast_portable::NO_PAD.

Instead of offering a simpler way to do this through a top-level function, 6 of the 9 top-level functions now take an Engine; I would argue that, in case you already have an engine, these could have been methods attached to it.

I understand that the Engine abstraction is useful if you want to introduce a SIMD-backed implementation. I even like the introduction of a separate Alphabet type. I think it doesn't really make sense to have a Config type that doesn't include Alphabet, keeping it separate instead -- the whole point of having a Config type is to make it easy to wrap all the contextual/usually stable input for your main API calls into a single type. But to not offer a top-level API that makes it easy to use different alphabets/config seems to me like a lack of empathy for how this crate is used.

(FWIW, I also think jumping from 0.13 to 0.20 doesn't have much merit.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions