Version: 5.2.1
3 Encoding
| (require (planet murphy/protobuf/encoding)) |
Low-level functions dealing with the binary wire format of protocol
buffers.
| (read-uint* [in max-size]) | | → (or/c exact-nonnegative-integer? eof-object?) | | in : input-port? = (current-input-port) | | max-size : (or/c exact-positive-integer? #f) = 10 |
|
| (write-uint* n [out max-size]) → void? | | 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-sint* [in max-size]) → (or/c exact-integer? eof-object?) | | in : input-port? = (current-input-port) | | max-size : (or/c exact-positive-integer? #f) = 10 |
|
| (write-sint* i [out max-size]) → void? | | i : exact-integer? | | out : output-port? = (current-output-port) | | max-size : (or/c exact-positive-integer? #f) = 10 |
|
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.
| (read-int* [in]) → (or/c exact-integer? eof-object?) | | in : input-port? = (current-input-port) |
|
| (write-int* i [out]) → void? | | 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.
| (read-bool [in]) → (or/c bool? eof-object?) | | in : input-port? = (current-input-port) |
|
| (write-bool v [out]) → void? | | v : any/c | | out : output-port? = (current-output-port) |
|
Read/write a boolean as a one byte integer.
| (read-fixed32 [in]) | | → (or/c exact-nonnegative-integer? eof-object?) | | in : input-port? = (current-input-port) |
|
| (read-fixed64 [in]) | | → (or/c exact-nonnegative-integer? eof-object?) | | in : input-port? = (current-input-port) |
|
| (write-fixed32 n [out]) → void? | | n : exact-nonnegative-integer? | | out : output-port? = (current-output-port) |
|
| (write-fixed64 n [out]) → void? | | 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.
| (read-sfixed32 [in]) → (or/c exact-integer? eof-object?) | | in : input-port? = (current-input-port) |
|
| (read-sfixed64 [in]) → (or/c exact-integer? eof-object?) | | in : input-port? = (current-input-port) |
|
| (write-sfixed32 i [out]) → void? | | i : exact-integer? | | out : output-port? = (current-output-port) |
|
| (write-sfixed64 i [out]) → void? | | 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.
| (read-float [in]) → (or/c real? eof-object?) | | in : input-port? = (current-input-port) |
|
| (read-double [in]) → (or/c real? eof-object?) | | in : input-port? = (current-input-port) |
|
| (write-float x [out]) → void? | | x : real? | | out : output-port? = (current-output-port) |
|
| (write-double x [out]) → void? | | 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.
| (read-sized-bytes [in]) → (or/c bytes? eof-object?) | | in : input-port? = (current-input-port) |
|
| (write-sized-bytes bstr [out]) → void? | | 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*.
| (read-sized-string [in]) → (or/c string? eof-object?) | | in : input-port? = (current-input-port) |
|
| (write-sized-string str [out]) → void? | | 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*.
| (read-sized read [in]) → any/c | | read : (-> input-port? any/c) | | in : input-port? = (current-input-port) |
|
| (write-sized write v [out]) → any | | 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.
| (read-tag/type [in]) | | | → | | | (or/c tag/c eof-object?) | | (or/c exact-nonnegative-integer? eof-object?) |
|
| | in : input-port? = (current-input-port) |
|
| (write-tag/type tag type [out]) → void? | | 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.