module Protobuf::Decoder

def decode(stream, message)

Read bytes from +stream+ and pass to +message+ object.
def decode(stream, message)
  until stream.eof?
    tag, wire_type = read_key(stream)
    bytes =
      case wire_type
      when WireType::VARINT then
        read_varint(stream)
      when WireType::FIXED64 then
        read_fixed64(stream)
      when WireType::LENGTH_DELIMITED then
        read_length_delimited(stream)
      when WireType::START_GROUP then
        read_start_group(stream)
      when WireType::END_GROUP then
        read_end_group(stream)
      when WireType::FIXED32 then
        read_fixed32(stream)
      else
        raise InvalidWireType, wire_type
      end
    message.set_field(tag, bytes)
  end
  message
end