@staticmethod
def vint(buf, pos):
    """Load variable-size int."""
    limit = min(pos + 11, len(buf))
    res = ofs = 0
    while pos < limit:
        b = int(buf[pos])
        res += (b & 127) << ofs
        pos += 1
        ofs += 7
        if b < 128:
            return res, pos
    return 0, -1
