Liking cljdoc? Tell your friends :D

clj-cbor.core

Core CBOR library API.

Core CBOR library API.
raw docstring

cbor-codecclj

(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:

  • :dispatch function which is called to provide a dispatch value based on the data to be encoded. (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:

- `:dispatch` function which is called to provide a dispatch value based on
  the data to be encoded. (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.
sourceraw docstring

decodeclj

(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`.
sourceraw docstring

decode-seqclj

(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.
sourceraw docstring

default-codecclj

Default CBOR codec to use when none is specified.

Default CBOR codec to use when none is specified.
sourceraw docstring

default-read-handlersclj

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`.
sourceraw docstring

default-write-handlersclj

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).
sourceraw docstring

dispatch-superclassesclj

(dispatch-superclasses & classes)

Construct a codec dispatch function which will return the named classes whenever one of their instances is encountered.

This lets you use a single superclass to match all of its subclasses. The classes are tested in the order given; if none match, this returns the value's own class.

Construct a codec dispatch function which will return the named classes
whenever one of their instances is encountered.

This lets you use a single superclass to match all of its subclasses. The
classes are tested in the order given; if none match, this returns the
value's own class.
sourceraw docstring

encodeclj

(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.
sourceraw docstring

encode-seqclj

(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.
sourceraw docstring

self-describeclj

(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.
sourceraw docstring

slurpclj

(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.
sourceraw docstring

slurp-allclj

(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.
sourceraw docstring

spitclj

(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.
sourceraw docstring

spit-allclj

(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.
sourceraw docstring

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

× close