Serialization, on top of what the generated code produces.
Generated X->proto / proto->X fns are Message-in/Message-out — they never
touch bytes. This namespace is the other half: Message to bytes and back.
Typical round trip:
(-> rec HelloRequest->proto pb/encode) ; -> bytes
(->> bytes (pb/decode HelloRequest-prototype) proto->HelloRequest)
decode takes the generated X-prototype var — the same value everything
else in the contract keys off — so there is exactly one handle per message
type in user code.
Serialization, on top of what the generated code produces.
Generated `X->proto` / `proto->X` fns are Message-in/Message-out — they never
touch bytes. This namespace is the other half: Message to bytes and back.
Typical round trip:
(-> rec HelloRequest->proto pb/encode) ; -> bytes
(->> bytes (pb/decode HelloRequest-prototype) proto->HelloRequest)
`decode` takes the generated `X-prototype` var — the same value everything
else in the contract keys off — so there is exactly one handle per message
type in user code.(decode prototype input)Parse one message. prototype is the generated X-prototype var; input
is a byte array, ByteString, ByteBuffer, or InputStream (read to the end).
Parse one message. `prototype` is the generated `X-prototype` var; `input` is a byte array, ByteString, ByteBuffer, or InputStream (read to the end).
(decode-delimited prototype in)Parse one length-prefixed message from a stream; nil at end of stream.
Parse one length-prefixed message from a stream; nil at end of stream.
(encode msg)(encode msg out)Message -> bytes. With an OutputStream, writes to it and returns it.
Message -> bytes. With an OutputStream, writes to it and returns it.
(encode-delimited msg out)Write msg length-prefixed, for framed streams of messages.
Write msg length-prefixed, for framed streams of messages.
(unknown-fields msg)The unknown fields protobuf-java preserved on a parsed Message. Preserved on
the Message; necessarily dropped by a record round trip (proto->X reads
declared fields only), so re-encoding a record is not byte-identical to the
original when unknown fields were present. Inspect them here when that
matters.
The unknown fields protobuf-java preserved on a parsed Message. Preserved on the Message; necessarily dropped by a record round trip (`proto->X` reads declared fields only), so re-encoding a record is not byte-identical to the original when unknown fields were present. Inspect them here when that matters.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |