def _VarintDecoder(mask, result_type):
def DecodeVarint(buffer, pos):<EOL><INDENT>result = <NUM_LIT:0><EOL>shift = <NUM_LIT:0><EOL>while <NUM_LIT:1>:<EOL><INDENT>b = six.indexbytes(buffer, pos)<EOL>result |= ((b & <NUM_LIT>) << shift)<EOL>pos += <NUM_LIT:1><EOL>if not (b & <NUM_LIT>):<EOL><INDENT>result &= mask<EOL>result = result_type(result)<EOL>return (result, pos)<EOL><DEDENT>shift += <NUM_LIT:7><EOL>if shift >= <NUM_LIT:64>:<EOL><INDENT>raise _DecodeError('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>return DecodeVarint<EOL>
Return an encoder for a basic varint value (does not include tag).

    Decoded values will be bitwise-anded with the given mask before being
    returned, e.g. to limit them to 32 bits.  The returned decoder does not
    take the usual "end" parameter -- the caller is expected to do bounds checking
    after the fact (often the caller can defer such checking until later).  The
    decoder returns a (value, new_pos) pair.