Liking cljdoc? Tell your friends :D

clj-protobuf.runtime

The runtime half of protoc-gen-clojure's generated-code contract.

Generated files call exactly four things here: file-descriptor to rebuild their embedded FileDescriptorProto, known-file for well-known-type deps, message for a prototype per message, and field for a handle per field. Everything protobuf decides per edition — presence, delimited encoding, utf8 validation, packedness — is resolved by protobuf-java when the descriptor is built, which is why generated code never mentions editions at all.

field returns a precomputed FieldHandle rather than a bare FieldDescriptor: the codec's hot path dispatches on a keyword and never touches the descriptor API per call. Handles are built against a specific prototype, so a message-typed field's nested prototype has the right concrete class in both the DynamicMessage and generated-class arms.

The runtime half of protoc-gen-clojure's generated-code contract.

Generated files call exactly four things here: `file-descriptor` to rebuild
their embedded FileDescriptorProto, `known-file` for well-known-type deps,
`message` for a prototype per message, and `field` for a handle per field.
Everything protobuf decides per edition — presence, delimited encoding, utf8
validation, packedness — is resolved by protobuf-java when the descriptor is
built, which is why generated code never mentions editions at all.

`field` returns a precomputed FieldHandle rather than a bare FieldDescriptor:
the codec's hot path dispatches on a keyword and never touches the descriptor
API per call. Handles are built against a specific prototype, so a
message-typed field's nested prototype has the right concrete class in both
the DynamicMessage and generated-class arms.
raw docstring

compiled-messageclj

(compiled-message fd lookup)

A compiled-codec prototype, whatever the codec setting.

A compiled-codec prototype, whatever the codec setting.
sourceraw docstring

dynamic-messageclj

(dynamic-message fd lookup)

A DynamicMessage prototype, whatever the codec setting: the reference arm, for tests and comparisons.

A DynamicMessage prototype, whatever the codec setting: the reference
arm, for tests and comparisons.
sourceraw docstring

fieldclj

(field prototype field-name)

A precomputed handle for one field of a message prototype, looked up by its exact proto field name — the name is the authority; kebab-cased keys are derived from it, never the reverse (STYLE_LEGACY files can mix conventions).

A precomputed handle for one field of a message prototype, looked up by its
exact proto field name — the name is the authority; kebab-cased keys are
derived from it, never the reverse (STYLE_LEGACY files can mix conventions).
sourceraw docstring

file-descriptorclj

(file-descriptor descriptor-b64 deps)

Build a FileDescriptor from the base64 FileDescriptorProto a generated file embeds, linked against its dependencies (already-built FileDescriptors — sibling namespaces' file-descriptor vars or known-file results).

Build a FileDescriptor from the base64 FileDescriptorProto a generated file
embeds, linked against its dependencies (already-built FileDescriptors —
sibling namespaces' `file-descriptor` vars or `known-file` results).
sourceraw docstring

known-fileclj

(known-file path)

The FileDescriptor for a well-known type bundled in protobuf-java, e.g. "google/protobuf/timestamp.proto".

The FileDescriptor for a well-known type bundled in protobuf-java, e.g.
"google/protobuf/timestamp.proto".
sourceraw docstring

messageclj

(message fd lookup)
(message fd lookup class-hint)

The prototype for a message type: a default instance whose .newBuilderForType the generated ->proto fns drive.

With a Java class hint (3-arity) the generated class's default instance is used when it is present and describes the same message — protoc's own serializer, and the fastest arm. Otherwise, and always in the 2-arity, the compiled codec's prototype: a Message over a slot array with the descriptor compiled once into reader and writer tables. DynamicMessage serves only for extendable types, which the compiled codec does not support, or when -Dclj-protobuf.codec=dynamic asks for it. Same codec, same field descriptors, same bytes on every arm.

The prototype for a message type: a default instance whose
`.newBuilderForType` the generated `->proto` fns drive.

With a Java class hint (3-arity) the generated class's default instance is
used when it is present and describes the same message — protoc's own
serializer, and the fastest arm. Otherwise, and always in the 2-arity, the
compiled codec's prototype: a Message over a slot array with the
descriptor compiled once into reader and writer tables. DynamicMessage
serves only for extendable types, which the compiled codec does not
support, or when -Dclj-protobuf.codec=dynamic asks for it. Same codec,
same field descriptors, same bytes on every arm.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close