Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

high-level API: simplify encoding a whole number of bytes #1

Open
dkg opened this issue Feb 11, 2022 · 0 comments · May be fixed by #5
Open

high-level API: simplify encoding a whole number of bytes #1

dkg opened this issue Feb 11, 2022 · 0 comments · May be fixed by #5

Comments

@dkg
Copy link

dkg commented Feb 11, 2022

The high-level encode function is still slightly unergonomic for the common use case of encoding a whole number of bytes.

As far as i can tell, the only errors possible for encode are:

  • bits doesn't match length of input
  • total encoded value will exceed the ability to allocate RAM

For the common use case it would be nice to have something like:

pub fn encode_full_bytes(input: &[u8]) -> Result(String, ZBase32Error)

or even (treating memory allocation failures as unrecoverable errors):

pub fn encode_full_bytes(input: &[u8]) -> String

(this latter interface is offered by the popular zbase32 crate, so implementing it would make it easier for people to move from zbase32 to this implementation)

dkg added a commit to dkg/libzbase32 that referenced this issue Feb 12, 2022
This is a much simpler function for a caller that knows they're always
dealing with ranges of full bytes.

Closes: DaGenix#1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant