Liking cljdoc? Tell your friends :D

pronto.core


->kebab-caseclj

(->kebab-case s)

Converts s, assumed to be in snake_case, to kebab-case

Converts `s`, assumed to be in snake_case, to kebab-case
sourceraw docstring

assoc-ifclj

(assoc-if m k v)
source

bytes->proto-mapcljmacro

(bytes->proto-map mapper clazz bytes)

Deserializes bytes into a proto-map for the given clazz

Deserializes `bytes` into a proto-map for the given `clazz`
sourceraw docstring

clear-fieldclj

(clear-field m k)
source

clear-field!clj

(clear-field! m k)
source

clj-map->proto-mapcljmacro

(clj-map->proto-map mapper clazz m)

Translate a map to a proto-map for the supplied class using mapper m. The converted map must not violate the class schema, i.e, it must have matching keyword names as well as value types.

Translate a map to a proto-map for the supplied class using mapper `m`.
The converted map must not violate the class schema, i.e, it must have matching
keyword names as well as value types.
sourceraw docstring

defmappercljmacro

(defmapper name classes & opts)

Define a new proto mapper for the supplied classes using the supplied options.

Supported options: :key-name-fn - a function that maps a field name, default identity

:enum-value-fn - a function that maps enum values, default identity

:iter-xf - a transducer for key-value map pairs

:encoders - encoders map, {class->{:from-proto fn, :to-proto fn}}

Define a new proto mapper for the supplied classes using the supplied options.

Supported options:
:key-name-fn - a function that maps a field name, default `identity`

:enum-value-fn - a function that maps enum values, default `identity`

:iter-xf - a transducer for key-value map pairs

:encoders - encoders map, `{class->{:from-proto fn, :to-proto fn}}`
sourceraw docstring

dependenciesclj

(dependencies clazz)

Return class dependencies for clazz.

Return class dependencies for `clazz`.
sourceraw docstring

depends-on?clj

(depends-on? dependent dependency)
source

has-field?clj

(has-field? m k)

Returns true iff field k is set in m. k must be a message type (i.e, non-scalar).

Returns true iff field `k` is set in `m`.
`k` must be a message type (i.e, non-scalar).
sourceraw docstring

hintcljmacro

(hint proto-map clazz mapper)

Create a new hint for proto-map for use by p-> calls. clazz must resolve to the Java protobuf class of the underlying POJO contained within proto-map. mapper must resolve to a mapper var created via defmapper.

For example:

(p/p-> (p/hint my-map MyClass my-mapper) :field_0 field_1).

This is equivalent to writing (p/p-> my-map :field_0 :field_1), except that the produced code will be optimized using the hint of the underlying type.

See also: with-hints

Create a new hint for `proto-map` for use by p-> calls.
`clazz` must resolve to the Java protobuf class of the underlying POJO contained within `proto-map.`
`mapper` must resolve to a mapper var created via `defmapper`.

For example:

`(p/p-> (p/hint my-map MyClass my-mapper) :field_0 field_1)`.

This is equivalent to writing `(p/p-> my-map :field_0 :field_1)`, except that the
produced code will be optimized using the hint of the underlying type.

See also: `with-hints`
sourceraw docstring

one-ofclj

(one-of m k)

Returns the value of the field which is set for k, a one-of type (or nil if none set).

Returns the value of the field which is set for `k`,
a one-of type (or `nil` if none set).
sourceraw docstring

p->cljmacro

(p-> x & forms)

Like -> but meant to be used where the initial expression evaluates to a proto-map. Under the hood, p-> will operate on a transient version of the proto-map and persistent! it back when done. Expressions will be pipelined as much as possible (but never reordered) such that (p-> person-proto (assoc-in [:pet :name] "patch") (assoc-in [:pet :kind] :cat)) will only generate a single instance of a pet transient map to which both operations will be applied in succession.

Like `->` but meant to be used where the initial expression evaluates to a proto-map. Under the hood, `p->` will operate on a transient version of the proto-map and `persistent!` it back when done. Expressions will be pipelined as much as possible (but never reordered) such that `(p-> person-proto (assoc-in [:pet :name] "patch") (assoc-in [:pet :kind] :cat))` will only generate a single instance of a pet transient map to which both operations will be applied in succession.
sourceraw docstring

pcond->cljmacro

(pcond-> expr & clauses)

Equivalent to cond->. See p->

Equivalent to cond->. See `p->`
sourceraw docstring

proto->proto-mapclj

(proto->proto-map mapper proto)

Wraps a new proto-map around proto, a POJO.

Wraps a new proto-map around `proto`, a POJO.
sourceraw docstring

proto-mapcljmacro

(proto-map mapper clazz & kvs)

Returns a new proto-map for the supplied class, via mapper, initialized to the optionally supplied key-value pairs.

Returns a new proto-map for the supplied class, via `mapper`, initialized
to the optionally supplied key-value pairs.
sourceraw docstring

proto-map->bytesclj

(proto-map->bytes proto-map)

Serializes proto-map to protobuf binary

Serializes `proto-map` to protobuf binary
sourceraw docstring

proto-map->clj-mapclj

(proto-map->clj-map proto-map)
(proto-map->clj-map proto-map xform)

Recursively converts a proto-map to a regular Clojure map.

Recursively converts a proto-map to a regular Clojure map.
sourceraw docstring

proto-map->protoclj

(proto-map->proto m)

Returns the protobuf instance associated with the proto-map

Returns the protobuf instance associated with the proto-map
sourceraw docstring

proto-map?clj

(proto-map? m)
source

remapclj

(remap mapper proto-map)

Remaps proto-map using mapper. The returned proto-map is subject to the configuration of the new mapper.

Remaps `proto-map` using `mapper`.
The returned proto-map is subject to the configuration of the new mapper.
sourceraw docstring

remove-default-values-xfclj

source

which-one-ofclj

(which-one-of m k)

Returns a keyword corresponding to which field is set for k, a one-of type (or nil if none set).

Returns a keyword corresponding to which field is set for `k`,
a one-of type (or `nil` if none set).
sourceraw docstring

with-hintscljmacro

(with-hints hints & body)

Takes a vector of hints (see hint), and introduces a scope within which all hinted variables will be type hinted in p-> calls, then executes & returns the value of body.

For example:

(defn foo [m] (p/with-hints [(p/hint m MyClass my-mapper)] {:height (p/p-> m :height) :name (p/p-> m :name)}))

Since m is hinted in the scope, both p-> calls will use the hint to produce more performant code.

Note that with-hints only applies to p-> calls directly within body, and not recursively. Therefore, the following code will not be hinted:

` (defn get-person-name [person-proto-map] (p/p-> person-proto-map :name))

(with-hints [(p/hint my-map MyClass my-mapper)] (get-person-name my-map )) `

Takes a vector of hints (see `hint`), and introduces a scope within which all hinted variables will be type hinted in `p->` calls, then executes & returns the value of `body.`

For example:

`(defn foo [m]
   (p/with-hints [(p/hint m MyClass my-mapper)]
     {:height (p/p-> m :height)
      :name   (p/p-> m :name)}))`

Since `m` is hinted in the scope, both p-> calls will use the hint to produce more performant code.

Note that with-hints only applies to p-> calls directly within `body`, and not recursively. Therefore, the following code will not be hinted:

`
(defn get-person-name [person-proto-map]
  (p/p-> person-proto-map :name))

(with-hints
  [(p/hint my-map MyClass my-mapper)]
  (get-person-name my-map ))
`
sourceraw docstring

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

× close