Liking cljdoc? Tell your friends :D

clojobuf-codec.decode

Read protobuf's Tag-Len-Val or Tag-Val encoded data, where: (1) Tag is varint encoded containing wire-type (lowest 3-bits) packed with field number (2) Len is varint encoded containing number of bytes that Val occupy; only present of wire-type 2 (3) Val is varint encoded for wire-type 0, or a fixed length for wire-type 1 and 5, or N bytes (where N = Len) for wire-type 2

Wire-Type 0 VARINT int32, int64, uint32, uint64, sint32, sint64, bool, enum 1 I64 fixed64, sfixed64, double 2 LEN string, bytes, embedded messages, packed repeated fields 3 SGROUP group start (deprecated) 4 EGROUP group end (deprecated) 5 I32 fixed32, sfixed32, float Note SGROUP and EGROUP are not supported

For more info https://developers.google.com/protocol-buffers/docs/encoding

Decoding a protobuf encoded binary is a 2 steps process performed repeatedly: (1) call (read-tag rr) to get field-id and wire-type (2) look up field-id in your protobuf schema to determine field-type (A) field-type == primitive (a) not :bytes && wire-type 2 => (read-packed rr field-type) (b) all other cases => (read-pri rr field-type) (B) field-type == map<key-type, value-type> (a) value-type is msg => (read-kv-msg rr key-type) (b) value-type is enum => (read-kv-enum rr key-type) (c) value-type is primitive => (read-kv-pri rr key-type) (C) field-type == message => (read-len-coded-bytes rr) where rr is clojobuf-codec.io.reader.ByteReader reading the binary.

If look up of field-id fails, then sender is using a schema with additional fields. Use read-raw-wire to extract the value generically and continue.

If look up of field-id yields a field-type incompatible with the wire-type, then sender is using a schema that has breaking change. If you want to continue decoding, you must honour the wire-type and use read-raw-wire to preserve the correctness of Tag-(Len-)Value boundary.

Read protobuf's Tag-Len-Val or Tag-Val encoded data, where:
   (1) Tag is varint encoded containing wire-type (lowest 3-bits) packed with
       field number
   (2) Len is varint encoded containing number of bytes that Val occupy; only
       present of wire-type 2
   (3) Val is varint encoded for wire-type 0, or a fixed length for wire-type
       1 and 5, or N bytes (where N = Len) for wire-type 2
   
   Wire-Type
   0	VARINT  int32, int64, uint32, uint64, sint32, sint64, bool, enum
   1	I64	    fixed64, sfixed64, double
   2	LEN     string, bytes, embedded messages, packed repeated fields
   3	SGROUP  group start (deprecated)
   4	EGROUP  group end (deprecated)
   5	I32     fixed32, sfixed32, float
   Note SGROUP and EGROUP are not supported
   
   For more info https://developers.google.com/protocol-buffers/docs/encoding
 
Decoding a protobuf encoded binary is a 2 steps process performed repeatedly:
  (1) call `(read-tag rr)` to get `field-id` and `wire-type`
  (2) look up `field-id` in your protobuf schema to determine `field-type`
      (A) `field-type` == primitive
          (a) not :bytes && wire-type 2 => `(read-packed rr field-type)`
          (b) all other cases           => `(read-pri    rr field-type)`
      (B) `field-type` == map<key-type, value-type>
          (a) value-type is msg         => `(read-kv-msg  rr key-type)`
          (b) value-type is enum        => `(read-kv-enum rr key-type)`
          (c) value-type is primitive   => `(read-kv-pri  rr key-type)`
      (C) `field-type` == message     => `(read-len-coded-bytes rr)`
where `rr` is `clojobuf-codec.io.reader.ByteReader` reading the binary.

If look up of `field-id` fails, then sender is using a schema with additional
fields. Use `read-raw-wire` to extract the value generically and continue.
   
If look up of `field-id` yields a `field-type` incompatible with the `wire-type`,
then sender is using a schema that has breaking change. If you want to continue
decoding, you must honour the wire-type and use `read-raw-wire` to preserve the
correctness of Tag-(Len-)Value boundary.
raw docstring

read-len-coded-bytesclj/s

(read-len-coded-bytes reader)

Read the next value as varint N, and return the next N bytes as binary.

Read the next value as varint N, and return the next N bytes as binary.
sourceraw docstring

read-packedclj/s

(read-packed reader packed-type)

Read length encoded packed data return it as a vector. packed-type = :int32 | :int64 | :uint32 :uint64 | :sint32 | :sint64 | :bool | :enum :fixed32 | :sfixed32 | float | :fixed64 | :sfixed64 | double

Read length encoded packed data return it as a vector.
packed-type = :int32 | :int64 | :uint32 :uint64 | :sint32 | :sint64 | :bool | :enum
              :fixed32 | :sfixed32 | float |
              :fixed64 | :sfixed64 | double
sourceraw docstring

read-priclj/s

(read-pri reader field-type)

Read a single primitive value, where field-type = :int32 | :int64 | :uint32 :uint64 | :sint32 | :sint64 | :bool | :enum :fixed32 | :sfixed32 | :float | :fixed64 | :sfixed64 | :double | :string | :bytes

Read a single primitive value, where
field-type = :int32 | :int64 | :uint32 :uint64 | :sint32 | :sint64 | :bool | :enum
             :fixed32 | :sfixed32 | :float |
             :fixed64 | :sfixed64 | :double |
             :string | :bytes
sourceraw docstring

read-raw-wireclj/s

(read-raw-wire reader wire-type)

Read next value generically based on wire-type. This function is typically used iff the actual field type is unknown or incompatible with the wire-type. wire-type 0 => read as varint64, return as int64 wire-type 1 => read as sfixed64, return as int64 wire-type 2 => read as len-value, return as binary wire-type 5 => read as sfixed32, return as int32

Read next value generically based on wire-type. This function is typically used iff
the actual field type is unknown or incompatible with the wire-type.
  wire-type 0 => read as varint64, return as int64
  wire-type 1 => read as sfixed64, return as int64
  wire-type 2 => read as len-value, return as binary
  wire-type 5 => read as sfixed32, return as int32
sourceraw docstring

read-tagclj/s

(read-tag reader)

Read the next value as varint and unpack it as [field-id wire-type] by assuming wire-type occupies lowest 3 bits. Returns [field-id wire-type].

Read the next value as varint and unpack it as [field-id wire-type] by
assuming wire-type occupies lowest 3 bits. Returns [field-id wire-type].
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close