We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello! Thank you for the great library! I I want to add support for varint.
varint
Link: https://en.wikipedia.org/wiki/Variable-length_quantity
The text was updated successfully, but these errors were encountered:
It would be nice to have both variants for little and big endian encodings, and maybe also zig-zag encoding.
Sorry, something went wrong.
If there is any interest, this is the big-ending version w/ overflow handling that I'm using:
#[inline] pub fn be_varint_u64<I, E: ParseError<I>>(mut i: I) -> IResult<I, u64, E> where I: Slice<RangeFrom<usize>> + InputIter<Item = u8> + InputLength, { let mut result = 0; 'end: { let mut byte; for _ in 0..(u64::BITS / 8) { (i, byte) = be_u8(i)?; result = (result << 7) + u64::from(byte & 0x7F); if byte < 0x80 { break 'end; } } (i, byte) = be_u8(i)?; result = (result << 8) + u64::from(byte); } Ok((i, result)) }
Because of the BITS associated constants this can't be a generic function, but should be easy enough to write a macro for it.
BITS
Successfully merging a pull request may close this issue.
Hello! Thank you for the great library! I I want to add support for
varint
.Link: https://en.wikipedia.org/wiki/Variable-length_quantity
The text was updated successfully, but these errors were encountered: