def encode_varint(i)
      raise ArgumentError, "int must be present" if !i
      raise ArgumentError, "int must be non-negative" if i < 0

      buf = if i <  0xfd
        [i].pack("C")
      elsif i <= 0xffff
        [0xfd, i].pack("Cv")
      elsif i <= 0xffffffff
        [0xfe, i].pack("CV")
      elsif i <= 0xffffffffffffffff
        [0xff, i].pack("CQ<")
      else
        raise ArgumentError, "Does not support integers larger 0xffffffffffffffff (i = 0x#{i.to_s(16)})"
      end

      buf
    end
def encode_varint(i)
      raise ArgumentError, "int must be present" if !i
      raise ArgumentError, "int must be non-negative" if i < 0

      buf = if i <  0xfd
        [i].pack("C")
      elsif i <= 0xffff
        [0xfd, i].pack("Cv")
      elsif i <= 0xffffffff
        [0xfe, i].pack("CV")
      elsif i <= 0xffffffffffffffff
        [0xff, i].pack("CQ<")
      else
        raise ArgumentError, "Does not support integers larger 0xffffffffffffffff (i = 0x#{i.to_s(16)})"
      end

      buf
    end
read_varint
 Encodes integer and returns its binary varint representation.