First let's consider the naive approach to var-int (var7) encoding.
In this scenario we just take each 7-bits of an encoded value and put them in chunks:
while value >= 0x80 {
let chunk = ((value as u8) & 0x7F) | 0x80;
buffer.push(chunk);
value >>= 7;
}