io.bullet.borer

Type members

Classlikes

trait AdtDecoder[T] extends Decoder[T]

An AdtDecoder is a Decoder whose read method expects to read an envelope (holding the type id) around the actual value encoding.

An AdtDecoder is a Decoder whose read method expects to read an envelope (holding the type id) around the actual value encoding.

In order to be able to collapse several envelope levels into a single one, when several AdtDecoder instances call each other, this type also provides read overloads which don't read the type id envelope themselves but can receive the type id from the outside.

trait AdtEncoder[T] extends Encoder[T]

An AdtEncoder is an Encoder which encodes its values with an envelope holding the value's type id.

An AdtEncoder is an Encoder which encodes its values with an envelope holding the value's type id.

It doesn't change or add to the outside interface of Encoder but merely serves as a marker signaling that it takes on the responsibility of encoding the type id in addition to the value itself. This allows outside encoders calling an AdtEncoder to delegate this responsibility rather than performing the task themselves.

sealed abstract class AdtEncodingStrategy
Companion:
object
Companion:
class
object Borer

Main entry point into the CBOR API.

Main entry point into the CBOR API.

trait ByteAccess[Bytes]

Type class for providing basic access to a Bytes abstraction, as well as construction of a respective Output.

Type class for providing basic access to a Bytes abstraction, as well as construction of a respective Output.

Companion:
object
object ByteAccess
Companion:
class
Companion:
object
case object Cbor extends Target
final case class Codec[A](encoder: Encoder[A], decoder: Decoder[A])

A simple encapsulation of an Encoder and Decoder for the same type, as one entity.

A simple encapsulation of an Encoder and Decoder for the same type, as one entity.

Sometimes it's easier to supply just a single implicit for a type, rather than two. As an alternative to writing a separate Encoder and Decoder for type A you can also write a Codec for A. (Encoder and Decoder can be implicitly "unpacked" from a codec.)

However, in order to not hinder composability Codecs should only ever be supplied, never consumed. So, if you write an encoder, decoder or codec for a generic type, which itself requires implicitly available encoders and/or decoders for certain type parameters (like Encoder.forOption, for example) then you should never require implicitly available Codecs, but rather Encoders and Decoders separately.

Companion:
object
object Codec
Companion:
class
trait CommonApi[Config]
object DataItem

A simple mapping of CBOR data item types to bits for efficient masking.

A simple mapping of CBOR data item types to bits for efficient masking.

trait Decoder[T]

Type class responsible for reading an instance of type T from a Reader.

Type class responsible for reading an instance of type T from a Reader.

Companion:
object
object Decoder extends LowPrioDecoders
Companion:
class
final case class Default[+T](defaultValue: T)
Companion:
object
object Default
Companion:
class
object Dom

Simple Document Object Model (DOM) for CBOR.

Simple Document Object Model (DOM) for CBOR.

Practically all valid CBOR encodings can be decoded into this structure and vice versa. Provided as an alternative to plain Writer-based encoding and Reader-based decoding.

trait Encoder[T]

Type class responsible for writing an instance of type T to a Writer.

Type class responsible for writing an instance of type T to a Writer.

Companion:
object
object Encoder extends LowPrioEncoders
Companion:
class
final case class Float16(value: Float)

Wrapper for Float value that gets encoded to and decoded from 16-bit Half-Precision Floats (two-byte IEEE 754).

Wrapper for Float value that gets encoded to and decoded from 16-bit Half-Precision Floats (two-byte IEEE 754).

Companion:
object
object Float16

Logic for converting half-precision (16-bit) floats to and from bytes.

Logic for converting half-precision (16-bit) floats to and from bytes.

Source: https://stackoverflow.com/questions/6162651 (The author says it's public domain.)

The documented author's "extensions" have been removed for clean round-tripping to and from Float.

Companion:
class
trait Input[Bytes]

Mutable abstraction wrapping some source of bytes to serve as parser input.

Mutable abstraction wrapping some source of bytes to serve as parser input.

Companion:
object
final class InputReader[Config <: Config](parser: Parser[_], directParser: DirectJsonParser, receiverWrapper: () => Config, config: Config, val target: Target)

Stateful, mutable abstraction for reading a stream of CBOR or JSON data from the given input.

Stateful, mutable abstraction for reading a stream of CBOR or JSON data from the given input.

case object Json extends Target
object Logging

Facilities for on-the-side logging of either encoding or decoding progress, which can be useful for debugging problems with the input or custom codec logic.

Facilities for on-the-side logging of either encoding or decoding progress, which can be useful for debugging problems with the input or custom codec logic.

Logging can be done either before or after the input validation step, depending on your needs. If unsure, go for after-validation logging, at least initially. (This is also the default.) For example, to log decoding progress to the console you can say:

Cbor.decode(inputBytes).withPrintLogging().to[MyType]
sealed abstract class LowPrioDecoders
sealed abstract class LowPrioEncoders
sealed abstract class LowPrioNullable

In order to enable an alternative Option codec, which encodes None to null and Some to an unwrapped value you can import the members of this object with

In order to enable an alternative Option codec, which encodes None to null and Some to an unwrapped value you can import the members of this object with

import io.bullet.borer.NullOptions._
final case class Nullable[+T](value: T)
Companion:
object
object Nullable extends LowPrioNullable
Companion:
class
trait Output

Abstraction over serialization output.

Abstraction over serialization output.

The implementation can be either mutable or immutable.

Companion:
object
object Reader
abstract class Receiver

The common interface of all types that consume CBOR data. (On the reading as well as the writing side)

The common interface of all types that consume CBOR data. (On the reading as well as the writing side)

Companion:
object
object Receiver
Companion:
class
final case class SimpleValue(value: Int)

Abstraction for a "simple value" in CBOR-speak.

Abstraction for a "simple value" in CBOR-speak.

Value parameters:
value

the value's code

Companion:
object
Companion:
class
sealed abstract class Tag(val code: Long)

Abstraction for a "tag" in CBOR-speak.

Abstraction for a "tag" in CBOR-speak.

Value parameters:
code

the tag's code

Companion:
object
object Tag
Companion:
class
final case class TaggedValue[T](tag: Tag, value: T)
Companion:
object
Companion:
class
sealed abstract class Target

Super-type of the Cbor and Json objects.

Super-type of the Cbor and Json objects.

Used, for example, as the type of the target member of Reader and Writer instances, which allows custom logic to pick different (de)serialization approaches depending on whether the target is CBOR or JSON.

case object Undefined

Abstraction for the "undefined" value in CBOR-speak.

Abstraction for the "undefined" value in CBOR-speak.

object Utf8
final class Writer(val output: Output, var receiver: Receiver, val target: Target, config: Config)

Stateful, mutable abstraction for writing a stream of CBOR or JSON data to the given Output.

Stateful, mutable abstraction for writing a stream of CBOR or JSON data to the given Output.

Companion:
object
object Writer
Companion:
class

Types