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

Support creation of arbitrary length Unsigned BER integers from given bytes. #59

Merged
merged 5 commits into from
Sep 6, 2021

Conversation

ximon18
Copy link
Member

@ximon18 ximon18 commented May 3, 2021

No description provided.

Copy link
Member

@partim partim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent, the function should probably be named from_slice. I am trying to avoid the term bytes for anything that isn’t actually a bytes::Bytes (hence the use of octets instead of bytes). I don’t think it needs to be generic over AsRef<[u8]> – in fact, because you are copying, it might be better not to be.

I think I also would want to it return an error for a wrongly formatted slice. You need to do the check anyway, might as well error out if things go wrong.

Finally, since we are using bytes::Bytes all over the place, a function from_bytes would be nice that only copies if absolutely necessary (i.e., if it needs to stick a zero octet in front). Perhaps you somehow can use the testing logic for both functions?

src/encode/primitive.rs Outdated Show resolved Hide resolved
src/int.rs Outdated Show resolved Hide resolved
@partim
Copy link
Member

partim commented May 12, 2021

(I fixed the Clippy errors in main, so if you merge main, the CI errors should go away.)

@ximon18 ximon18 merged commit 321e22d into main Sep 6, 2021
@ximon18 ximon18 deleted the unsigned-from-slice branch September 6, 2021 08:52
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 this pull request may close these issues.

2 participants