fs2.data.cbor.low

Low-level representation and tools for CBOR data streams.

The low-level representation has two main goals:

  • it is a flat representation of the input stream, which allows for expressing collections that exceed the max size of Int.MaxValue
    • it doesn't interpret numbers, keeping their raw representation in memory.

This representation is useful when dealing with streams that may contain big collections or when it is not necessary to build an AST, as it is more efficient than the high-level one.

The data model follows closely the structure described in the RFC.

Type members

Classlikes

sealed trait CborItem

A low-level CBOR item. Items are emitted as soon as they are complete They can be used for reading/writing streamed CBOR data, including indefinite length arrays, maps, or strings.

A low-level CBOR item. Items are emitted as soon as they are complete They can be used for reading/writing streamed CBOR data, including indefinite length arrays, maps, or strings.

Companion:
object
object CborItem
Companion:
class

Value members

Concrete methods

def items[F[_]](implicit F: RaiseThrowable[F]): (F, Byte) => CborItem

Parses the input byte stream into a sequence of low-level CBOR items. This allows for parsing arbitrary long and deep CBOR data. No AST is built.

Parses the input byte stream into a sequence of low-level CBOR items. This allows for parsing arbitrary long and deep CBOR data. No AST is built.

def toBinary[F[_]](implicit F: RaiseThrowable[F]): (F, CborItem) => Byte

Transforms a stream of CBOR items into the binary representation.

Transforms a stream of CBOR items into the binary representation.

The resulting stream fails as soon as a problem is encounter.

def toNonValidatedBinary[F[_]]: (F, CborItem) => Byte

Transforms a stream of CBOR items into the binary representation.

Transforms a stream of CBOR items into the binary representation.

This produces a valid byte stream if the input item stream is well-formed, otherwise result is uncertain and will eventually produce an invalid byte sequence.

Use this pipe if you are sure the stream is well-formed or if it does not matter to produce ill-formed streams.

Since no validation is performed, this pipe is more efficient and allows for better throughput.

def validate[F[_]](implicit F: RaiseThrowable[F]): (F, CborItem) => CborItem

Validates the stream of CBOR items, emitting them unchanged.

Validates the stream of CBOR items, emitting them unchanged.

The resulting stream is failed as soon as a problem is encountered.