module Protobuf::Message::Serialization
def self.included(other)
def self.included(other) other.extend(ClassMethods) end
def decode(bytes)
Decode the given non-stream bytes into this message.
def decode(bytes) decode_from(::StringIO.new(bytes)) end
def decode_from(stream)
Decode the given stream into this message.
def decode_from(stream) ::Protobuf::Decoder.decode_each_field(stream) do |tag, bytes| set_field_bytes(tag, bytes) end self end
def encode
Encode this message
def encode stream = ::StringIO.new stream.set_encoding(::Protobuf::Field::BytesField::BYTES_ENCODING) encode_to(stream) stream.string end
def encode_to(stream)
Encode this message to the given stream.
def encode_to(stream) ::Protobuf::Encoder.encode(self, stream) end
def set_field_bytes(tag, bytes)
def set_field_bytes(tag, bytes) field = self.class.get_field(tag, true) field.set(self, bytes) if field end