5.3.6
3 Encoding
(require (planet murphy/protobuf/encoding)) |
Low-level functions dealing with the binary wire format of protocol
buffers.
procedure
→ (or/c exact-nonnegative-integer? eof-object?) in : input-port? = (current-input-port) max-size : (or/c exact-positive-integer? #f) = 10
procedure
n : exact-nonnegative-integer? out : output-port? = (current-output-port) max-size : (or/c exact-positive-integer? #f) = 10
Read/write a variable length unsigned integer. If max-size
is not false, it defines the maximum number of bytes that the
encoded number may use.
Read/write a variable length signed integer in zigzag encoding. If
max-size is not false, it defines the maximum number of
bytes that the encoded number may use.
procedure
in : input-port? = (current-input-port)
procedure
i : exact-integer? out : output-port? = (current-output-port)
Read/write a variable length signed integer in tows-complement
encoding. The maximum number of bytes used by the encoded number is
10, the maximum bit length of the number is 64.
procedure
in : input-port? = (current-input-port)
procedure
v : any/c out : output-port? = (current-output-port)
Read/write a boolean as a one byte integer.
procedure
→ (or/c exact-nonnegative-integer? eof-object?) in : input-port? = (current-input-port)
procedure
→ (or/c exact-nonnegative-integer? eof-object?) in : input-port? = (current-input-port)
procedure
n : exact-nonnegative-integer? out : output-port? = (current-output-port)
procedure
n : exact-nonnegative-integer? out : output-port? = (current-output-port)
Read/write unsigned integers as fixed length 32/64-bit values with little
endian byte order.
procedure
in : input-port? = (current-input-port)
procedure
in : input-port? = (current-input-port)
procedure
i : exact-integer? out : output-port? = (current-output-port)
procedure
i : exact-integer? out : output-port? = (current-output-port)
Read/write signed integers as fixed length 32/64-bit values in
twos-complement encoding with little endian byte order.
procedure
in : input-port? = (current-input-port)
procedure
in : input-port? = (current-input-port)
procedure
x : real? out : output-port? = (current-output-port)
procedure
x : real? out : output-port? = (current-output-port)
Read/write real numbers as fixed length 32/64-bit IEEE floating
point values with little endian byte order.
procedure
in : input-port? = (current-input-port)
procedure
bstr : bytes? out : output-port? = (current-output-port)
Read/write a byte string with size prefix. The size is read and
written using read-uint* and write-uint*.
procedure
in : input-port? = (current-input-port)
procedure
str : string? out : output-port? = (current-output-port)
Read/write a UTF-8 encoded string with size prefix. The size in
bytes is read and written using read-uint* and
write-uint*.
procedure
read : (-> input-port? any/c) in : input-port? = (current-input-port)
procedure
write : (-> any/c output-port? any) v : any/c out : output-port? = (current-output-port)
Read/write any object with size prefix. The size in bytes is read
and written using read-uint* and write-uint*.
On input, read is called on an input port limited according to the size prefix. On output, write is called on v and a byte string output port; the buffered output’s length is then written to the actual output port.
procedure
→
(or/c tag/c eof-object?) (or/c exact-nonnegative-integer? eof-object?) in : input-port? = (current-input-port)
procedure
tag : tag/c type : exact-nonnegative-integer? out : output-port? = (current-output-port)
Read/write the tag and type of a protocol buffer message field.
Contract matching any of the protocol buffer message field wire type
enumeration items:
'int*: The field value is encoded as a variable length integer.
'64bit: The field value is always encoded in 64 bits.
'32bit: The field value is always encoded in 32 bits.
'sized: The field value is encoded with a byte size prefix.