ToonCodec

zio.blocks.schema.toon.ToonCodec
See theToonCodec companion object
abstract class ToonCodec[A] extends BinaryCodec[A]

Abstract class for encoding and decoding values of type A to and from TOON formats. Encapsulates logic to map TOON representations into native type structures and vice versa, handling serialization and deserialization as per TOON encoding standards using UTF-8 character set.

This class requires an implementation for two core operations: decoding a value of type A from a TOON representation and encoding a value of type A into a TOON representation.

Attributes

Companion
object
Source
ToonCodec.scala
Graph
Supertypes
class BinaryCodec[A]
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def decodeValue(in: ToonReader): A

Attempts to decode a value of type A from the specified ToonReader, but may fail with ToonCodecError error if the TOON input does not encode a value of this type.

Attempts to decode a value of type A from the specified ToonReader, but may fail with ToonCodecError error if the TOON input does not encode a value of this type.

Value parameters

in

an instance of ToonReader that provides access to the TOON input to parse a TOON value to value of type A

Attributes

Source
ToonCodec.scala
def encodeValue(x: A, out: ToonWriter): Unit

Encodes the specified value using provided ToonWriter, but may fail with ToonCodecError if it cannot be encoded properly according to TOON specification requirements.

Encodes the specified value using provided ToonWriter, but may fail with ToonCodecError if it cannot be encoded properly according to TOON specification requirements.

Value parameters

out

an instance of ToonWriter that provides access to TOON output to serialize the specified value as a TOON value

x

the value provided for serialization

Attributes

Source
ToonCodec.scala

Concrete methods

override def decode(input: ByteBuffer): Either[SchemaError, A]

Decodes a value of type A from the specified ByteBuffer using the default configuration.

Decodes a value of type A from the specified ByteBuffer using the default configuration.

Value parameters

input

the byte buffer containing TOON input

Attributes

Returns

Either where the Left contains a SchemaError if decoding fails, or the Right contains the successfully decoded value of type A

Definition Classes
Source
ToonCodec.scala
def decode(input: ByteBuffer, config: ReaderConfig): Either[SchemaError, A]

Decodes a value of type A from the specified ByteBuffer using the provided configuration.

Decodes a value of type A from the specified ByteBuffer using the provided configuration.

Value parameters

config

the reader configuration to use for parsing

input

the byte buffer containing TOON input

Attributes

Returns

Either where the Left contains a SchemaError if decoding fails, or the Right contains the successfully decoded value of type A

Source
ToonCodec.scala
def decode(input: Array[Byte]): Either[SchemaError, A]

Attributes

Source
ToonCodec.scala
def decode(input: Array[Byte], config: ReaderConfig): Either[SchemaError, A]

Attributes

Source
ToonCodec.scala
def decode(input: InputStream): Either[SchemaError, A]

Attributes

Source
ToonCodec.scala
def decode(input: InputStream, config: ReaderConfig): Either[SchemaError, A]

Attributes

Source
ToonCodec.scala
def decode(input: String): Either[SchemaError, A]

Attributes

Source
ToonCodec.scala
def decode(input: String, config: ReaderConfig): Either[SchemaError, A]

Attributes

Source
ToonCodec.scala
def decodeInlineArray(in: ToonReader, values: Array[String], expectedLength: Int): A

Decodes an inline array from comma-separated string values. Used for TOON's compact inline array format: xs[3]: 1,2,3

Decodes an inline array from comma-separated string values. Used for TOON's compact inline array format: xs[3]: 1,2,3

Value parameters

expectedLength

the expected length from the array header

values

array of string values parsed from the inline array

Attributes

Source
ToonCodec.scala
def decodeKey(in: ToonReader): A

Attempts to decode a value of type A from the specified ToonReader, but may fail with ToonCodecError error if the TOON input is not a key or does not encode a value of this type.

Attempts to decode a value of type A from the specified ToonReader, but may fail with ToonCodecError error if the TOON input is not a key or does not encode a value of this type.

Value parameters

in

an instance of ToonReader that provides access to the TOON input to parse a TOON key to value of type A

Attributes

Source
ToonCodec.scala
def decodeListArray(in: ToonReader, expectedLength: Int): A

Decodes a list-format array where each item is prefixed with -. Used for non-uniform objects or complex nested structures.

Decodes a list-format array where each item is prefixed with -. Used for non-uniform objects or complex nested structures.

Value parameters

expectedLength

the expected number of items from the array header

in

the ToonReader positioned at the first list item line

Attributes

Source
ToonCodec.scala
def decodeTabularArray(in: ToonReader, fieldNames: Array[String], expectedLength: Int, delimiter: Delimiter): A

Decodes a tabular array from field-value row data. Used for TOON's tabular format: items[2]{sku,qty,price}: followed by rows.

Decodes a tabular array from field-value row data. Used for TOON's tabular format: items[2]{sku,qty,price}: followed by rows.

Value parameters

delimiter

the delimiter to use for splitting rows

expectedLength

the expected number of rows

fieldNames

the field names from the header

in

the ToonReader positioned after the header line

Attributes

Source
ToonCodec.scala
def decodeTabularRow(in: ToonReader, values: Array[String], fieldNames: Array[String]): A

Decodes a single tabular row into a record value. Used when this codec's type is an element in a tabular array.

Decodes a single tabular row into a record value. Used when this codec's type is an element in a tabular array.

Value parameters

fieldNames

the field names from the tabular header

values

the values parsed from the row (one per field)

Attributes

Source
ToonCodec.scala
override def encode(value: A, output: ByteBuffer): Unit

Encodes the specified value to the given ByteBuffer using the default configuration.

Encodes the specified value to the given ByteBuffer using the default configuration.

Value parameters

output

the byte buffer to write TOON output to

value

the value to encode

Attributes

Definition Classes
Source
ToonCodec.scala
def encode(value: A, output: ByteBuffer, config: WriterConfig): Unit

Attributes

Source
ToonCodec.scala
def encode(value: A): Array[Byte]

Attributes

Source
ToonCodec.scala
def encode(value: A, config: WriterConfig): Array[Byte]

Attributes

Source
ToonCodec.scala
def encode(value: A, output: OutputStream): Unit

Attributes

Source
ToonCodec.scala
def encode(value: A, output: OutputStream, config: WriterConfig): Unit

Attributes

Source
ToonCodec.scala
def encodeAsField(fieldName: String, x: A, out: ToonWriter): Unit

Encodes the specified value as a field within a TOON record.

Encodes the specified value as a field within a TOON record.

Value parameters

fieldName

the name of the field

out

an instance of ToonWriter that provides access to TOON output

x

the value provided for serialization

Attributes

Source
ToonCodec.scala
def encodeKey(x: A, out: ToonWriter): Unit

Encodes the specified value using provided ToonWriter as a TOON key, but may fail with ToonCodecError if it cannot be encoded properly according to TOON specification requirements.

Encodes the specified value using provided ToonWriter as a TOON key, but may fail with ToonCodecError if it cannot be encoded properly according to TOON specification requirements.

Value parameters

out

an instance of ToonWriter that provides access to TOON output to serialize the specified value as a TOON key

x

the value provided for serialization

Attributes

Source
ToonCodec.scala
def encodeTabularRow(x: A, out: ToonWriter, delimiter: Delimiter): Unit

Encodes a value as a single row in tabular format (values only, no keys). Used when this codec's values are elements in a tabular array.

Encodes a value as a single row in tabular format (values only, no keys). Used when this codec's values are elements in a tabular array.

Value parameters

delimiter

the delimiter to use between values

out

the writer to output to

x

the value to encode

Attributes

Source
ToonCodec.scala
def encodeToString(value: A): String

Attributes

Source
ToonCodec.scala
def encodeToString(value: A, config: WriterConfig): String

Attributes

Source
ToonCodec.scala
def error(msg: String): Nothing

Attributes

Source
ToonCodec.scala
def error(span: Node, error: Throwable): Nothing

Attributes

Source
ToonCodec.scala