fn read_varint(input: &mut &[u8]) -> Result<u64, CidError>Expand description
Reads an unsigned LEB128 varint, advancing input past it.
Nine continuation bytes is already more than a u64 holds, so the length
cap is what stops a hostile string from being read forever.
The encoding must also be minimal, which multiformats requires of an
unsigned varint and which is not a tidiness here. A Cid keeps the bytes
it was read from and prints from them, so a version written 81 00 rather
than 01 is a second byte sequence, a second string and a second Cid
that compares unequal — for one block, with one digest. The rule is that
the last group of a multi-byte varint has to carry something, so a
terminating zero group after a continuation byte is refused.