(codec? v)
Returns if v
is a codec - both an encoder and a decoder.
Returns if `v` is a codec - both an encoder and a decoder.
(conditional c f & args)
Returns a codec for a tuple of values, where the codec for the
first one is c
and for the second it's (apply f v args)
where v
is
the first value.
Returns a codec for a tuple of values, where the codec for the first one is `c` and for the second it's `(apply f v args)` where `v` is the first value.
(decode codec codes)
Decodes the given sequence of codes
according to the given
codec
, returning a decoder-error?
or a tuple of [value rest-codes]
.
Decodes the given sequence of `codes` according to the given `codec`, returning a [[decoder-error?]] or a tuple of `[value rest-codes]`.
(decode-full codec codes)
Decodes the given sequence of codes
according to the given
codec
, returning the decoded value. Throws if there are unread
codes at the end, or too little codes for the codec, or any other
problem.
Decodes the given sequence of `codes` according to the given `codec`, returning the decoded value. Throws if there are unread codes at the end, or too little codes for the codec, or any other problem.
(-decode this codes)
Must return [value rest-codes] or a decoder-error
Must return [value rest-codes] or a decoder-error
(decoder-error msg & [data])
(decoder-error? v)
(encode codec value)
Encode with given value
according to the given codec
, returning
a sequence of codes.
Encode with given `value` according to the given `codec`, returning a sequence of codes.
(-encode this value)
Must return a sequence of codes representing the given value.
Must return a sequence of codes representing the given value.
(length-prefix length-codec coll-item-codec)
Returns a codec for a sequence of coll-item-codec
of any length,
where the length is encoded using length-codec
and placed before
the encoding of the collection items.
Returns a codec for a sequence of `coll-item-codec` of any length, where the length is encoded using `length-codec` and placed before the encoding of the collection items.
(record key c & more)
Returns a codec for some named elements with different codecs. The encoded value should be a map of the given keys, and the code is a concatenation of the encodings of each item. E.g. the names are not encoded. Example:
(record :a int8 :b uint32)
Returns a codec for some named elements with different codecs. The encoded value should be a map of the given keys, and the code is a concatenation of the encodings of each item. E.g. the names are not encoded. Example: (record :a int8 :b uint32)
(repeat n c)
Returns a codec that is a seq
of n
times the same codec repeated.
Returns a codec that is a [[seq]] of `n` times the same codec repeated.
(seq c & cs)
Returns a codec for a sequence of values, given codecs for each. The codes are concatenated into one.
Returns a codec for a sequence of values, given codecs for each. The codes are concatenated into one.
(simple-codec enc dec & args)
Creates a simple codec based on functions (apply enc value args)
to encode, and (apply dec codes args)
to decode.
Creates a simple codec based on functions `(apply enc value args)` to encode, and `(apply dec codes args)` to decode.
(simple-decoder dec & args)
Creates a simple decoder based on (apply dec value args)
to
encode.
Creates a simple decoder based on `(apply dec value args)` to encode.
(simple-encoder enc & args)
Creates a simple encoder based on (apply enc value args)
to
encode.
Creates a simple encoder based on `(apply enc value args)` to encode.
The codec for the value representing one item of the code itself. This is also some kind of 'identity' codec.
The codec for the value representing one item of the code itself. This is also some kind of 'identity' codec.
(translate c enc dec & args)
Returns a codec like c, but the value encoded by c is (apply f value args)
instead, and the decoded value of the returned value
is (apply g value args)
instead.
Returns a codec like c, but the value encoded by c is `(apply f value args)` instead, and the decoded value of the returned value is `(apply g value args)` instead.
(try-decode codec codes & [error-return])
Tries to decodes the given sequence of codes
according to the
given codec
, returning the decoded value if successfull. Returns
error-return
, which defaults to nil, if there are unread codes at
the end, or too little codes for the codec, or any other problem.
Tries to decodes the given sequence of `codes` according to the given `codec`, returning the decoded value if successfull. Returns `error-return`, which defaults to nil, if there are unread codes at the end, or too little codes for the codec, or any other problem.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close