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
Add support varint #1567
Comments
It would be nice to have both variants for little and big endian encodings, and maybe also zig-zag encoding. |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: