marshallpierce / rust-base64

base64, in rust
Apache License 2.0
615 stars 115 forks source link

[Request] Provide a public function that tells if a buffer is large enough #199

Closed c410-f3r closed 1 year ago

c410-f3r commented 1 year ago

The issue is that encode_config_buf panics if a buffer isn't large enough, which will abort the current thread preventing any type of graceful shutdown or alternative branch. Therefore, a public method should at least be provided to let users verify their buffers before issuing encode_config_buf.

marshallpierce commented 1 year ago

encoded_len is now public starting with 0.20.0-alpha.1: https://docs.rs/base64/0.20.0-alpha.1/base64/fn.encoded_len.html

(0.20 is fine to use in production, despite the alpha name, as long as you're OK with some further API changes by the time 0.20.0 final is released -- feedback on 0.20 changes welcome!)

c410-f3r commented 1 year ago

@marshallpierce Thank you for being open to adding new functionalities and for introducing the function.