struct
Proto::Wire::Writer
- Proto::Wire::Writer
- Struct
- Value
- Object
Overview
Writer wraps an IO and provides typed protobuf wire-format write primitives.
Typical message encode pattern: writer.write_tag(1, WireType::VARINT) writer.write_int32(value)
For embedded messages use write_embedded which buffers the sub-message, then writes the length prefix followed by the bytes.
Defined in:
proto/wire/writer.crConstant Summary
-
DEFAULT_MAX_FIELD_LENGTH =
(8 * 1024) * 1024
Constructors
Instance Method Summary
- #write_bool(value : Bool) : Nil
-
#write_bool_field(field_number : Int32, value : Bool) : Nil
Write a bool field only if value is true.
- #write_bytes(data : Bytes) : Nil
-
#write_bytes_field(field_number : Int32, value : Bytes) : Nil
Write a bytes field only if value is not empty.
- #write_double(value : Float64) : Nil
-
#write_embedded(field_number : Int32, & : IO -> ) : Nil
Write a length-delimited field by buffering the block's output.
- #write_fixed32(value : UInt32) : Nil
- #write_fixed64(value : UInt64) : Nil
- #write_float(value : Float32) : Nil
-
#write_int32(value : Int32) : Nil
int32: sign-extends to 64 bits (negative values become 10-byte varints)
-
#write_int32_field(field_number : Int32, value : Int32) : Nil
Write an int32 field only if value != 0.
- #write_int64(value : Int64) : Nil
-
#write_packed(field_number : Int32, & : IO::Memory -> ) : Nil
Write a packed repeated field using the block to write each element into the buffer.
- #write_sfixed32(value : Int32) : Nil
- #write_sfixed64(value : Int64) : Nil
-
#write_sint32(value : Int32) : Nil
sint32 / sint64 use zigzag encoding
- #write_sint64(value : Int64) : Nil
- #write_string(value : String) : Nil
-
#write_string_field(field_number : Int32, value : String) : Nil
Write a string field only if value is not empty.
- #write_tag(field_number : Int32, wire_type : Int32) : Nil
- #write_uint32(value : UInt32) : Nil
- #write_uint64(value : UInt64) : Nil
-
#write_uint64_field(field_number : Int32, value : UInt64) : Nil
Write a uint64 field only if value != 0.
- #write_varint(value : UInt64) : Nil
Constructor Detail
Instance Method Detail
Write a bool field only if value is true.
Write a bytes field only if value is not empty.
Write a length-delimited field by buffering the block's output. Yields the underlying IO::Memory; the accumulated bytes are length-prefixed and written.
int32: sign-extends to 64 bits (negative values become 10-byte varints)
Write an int32 field only if value != 0.
Write a packed repeated field using the block to write each element into the buffer. Skips writing the field entirely if the array is empty.
Write a string field only if value is not empty.
Write a uint64 field only if value != 0.