Core CBOR library API.
Core CBOR library API.
(cbor-codec & opts)
Construct a new CBOR codec with no configuration. Note that this does not
include any read and write handlers. See the default-codec
and the
default-read-handlers
and default-write-handlers
vars.
Arguments may be a map or a sequence of key/value pairs. Valid options are:
:write-dispatch
function which is called to provide a dispatch value
based on the data to be rendered. (default: class
):write-handlers
lookup function from dispatch values to handlers which
take some data to be encoded and return a transformed version of it
(typically a tagged value).:read-handlers
lookup function from integer tags to handlers which take
the embedded item and return the parsed data value.Construct a new CBOR codec with no configuration. Note that this does not include **any** read and write handlers. See the `default-codec` and the `default-read-handlers` and `default-write-handlers` vars. Arguments may be a map or a sequence of key/value pairs. Valid options are: - `:write-dispatch` function which is called to provide a dispatch value based on the data to be rendered. (default: `class`) - `:write-handlers` lookup function from dispatch values to handlers which take some data to be encoded and return a transformed version of it (typically a tagged value). - `:read-handlers` lookup function from integer tags to handlers which take the embedded item and return the parsed data value.
(decode input)
(decode decoder input)
(decode decoder input eof-guard)
Decode a single CBOR value from the input.
This uses the given codec or the default-codec
if none is provided. If at
the end of the input, this returns eof-guard
or nil.
The input must be an input stream or something coercible to one like a file
or byte array. Note that coercion will produce a BufferedInputStream
if the
argument is not already a stream, so repeated reads will probably not behave
as expected! If you need incremental parsing, make sure you pass in something
that is already an InputStream
.
Decode a single CBOR value from the input. This uses the given codec or the `default-codec` if none is provided. If at the end of the input, this returns `eof-guard` or nil. The input must be an input stream or something coercible to one like a file or byte array. Note that coercion will produce a `BufferedInputStream` if the argument is not already a stream, so repeated reads will probably not behave as expected! If you need incremental parsing, make sure you pass in something that is already an `InputStream`.
(decode-seq input)
(decode-seq decoder input)
Decode a sequence of CBOR values from the input.
This uses the given codec or the default-codec
if none is provided. The
returned sequence is lazy, so take care that the input stream is not closed
before the entries are realized.
The input must be an input stream or something coercible to one - see
decode
for usage notes.
Decode a sequence of CBOR values from the input. This uses the given codec or the `default-codec` if none is provided. The returned sequence is lazy, so take care that the input stream is not closed before the entries are realized. The input must be an input stream or something coercible to one - see `decode` for usage notes.
Default CBOR codec to use when none is specified.
Default CBOR codec to use when none is specified.
Map of default tag handlers to use, keyed by tag.
The default choice of representation for instants in time is
java.time.Instant
.
Map of default tag handlers to use, keyed by tag. The default choice of representation for instants in time is `java.time.Instant`.
Map of default write handlers to use, keyed by class.
The default choice of encoding for instants in time is the numeric epoch representation (tag 1).
Map of default write handlers to use, keyed by class. The default choice of encoding for instants in time is the numeric epoch representation (tag 1).
(encode value)
(encode encoder value)
(encode encoder output value)
Encode a single value as CBOR data.
Writes the value bytes to the provided output stream, or returns the value
as a byte array if no output is given. The default-codec
is used to encode
the value if none is provided.
Encode a single value as CBOR data. Writes the value bytes to the provided output stream, or returns the value as a byte array if no output is given. The `default-codec` is used to encode the value if none is provided.
(encode-seq values)
(encode-seq encoder values)
(encode-seq encoder output values)
Encode a sequence of values as CBOR data. This eagerly consumes the input sequence.
Writes the value bytes to the provided output stream, or returns the value
as a byte array if no output is given. The default-codec
is used to encode
the value if none is provided.
Encode a sequence of values as CBOR data. This eagerly consumes the input sequence. Writes the value bytes to the provided output stream, or returns the value as a byte array if no output is given. The `default-codec` is used to encode the value if none is provided.
(self-describe value)
Wraps a value with a self-describing CBOR tag. This will cause the first few
bytes of the data to be D9D9F7
, which serves as a distinguishing header for
format detection.
Wraps a value with a self-describing CBOR tag. This will cause the first few bytes of the data to be `D9D9F7`, which serves as a distinguishing header for format detection.
(slurp f & opts)
Opens an input stream from f
, reads the first value from it, then closes
the stream.
Opens an input stream from `f`, reads the first value from it, then closes the stream.
(slurp-all f & opts)
Opens an input stream from f
, reads all values from it, then closes the
stream.
Opens an input stream from `f`, reads all values from it, then closes the stream.
(spit f value & opts)
Opens an output stream to f
, writes value
to it, then closes the stream.
Options may include :append
to write to the end of the file instead of
truncating.
Opens an output stream to `f`, writes `value` to it, then closes the stream. Options may include `:append` to write to the end of the file instead of truncating.
(spit-all f values & opts)
Opens an output stream to f
, writes each element in values
to it, then
closes the stream.
Options may include :append
to write to the end of the file instead of
truncating.
Opens an output stream to `f`, writes each element in `values` to it, then closes the stream. Options may include `:append` to write to the end of the file instead of truncating.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close