Reference

std/yaml/decoder

std/yaml/src/decoder.trb

YamlDecoder: a Decoder over an expanded YAML tree, in which the target type resolves each scalar.

no is the text "no" where a String is read and an error where a Bool is - unless the document says %YAML 1.1, whose truth values yes, no, on and off are. A quoted scalar is always a text, and an explicit tag of the core schema (!!int "5") is honoured.

type YamlDecoder

type YamlDecoder with Decoder

A Decoder over a YAML node whose aliases and merge keys are resolved already. schema is the one of the document's version - Core, or Yaml11 for %YAML 1.1 - and says how null, truth values and numbers are spelled.

field line

protected var line: Int = 0

The line of the node that was taken last: where a failure points.

fn of

static fn of(node: YamlNode, schema: YamlSchema = YamlSchema.Core, naming: Naming = Naming.Unchanged, strict: Bool = false, tags: List<YamlTag> = []): YamlDecoder

A decoder that reads node, with the options of the format.

fn nothing

var fn nothing(): Bool

Not documented.

fn bool

var fn bool(): Result<Bool, DecodeError>

Not documented.

fn int

var fn int(): Result<Int64, DecodeError>

Not documented.

fn unsigned

var fn unsigned(): Result<UInt64, DecodeError>

Not documented.

fn float

var fn float(): Result<Float64, DecodeError>

Not documented.

fn decimal

var fn decimal(): Result<Decimal, DecodeError>

Not documented.

fn string

var fn string(): Result<String, DecodeError>

Any scalar is a text where a text is read: the target type decides.

fn bytes

var fn bytes(): Result<List<UInt8>, DecodeError>

A !!binary scalar or a base64 text, or a sequence of numbers that each fit into a byte.

fn sequence

var fn sequence(): Result<Int?, DecodeError>

A sequence, the keys of a !!set, the bytes of a !!binary scalar as a sequence of numbers - which is what a List<UInt8> reads - or nothing at all, which is an empty sequence.

fn map

var fn map(): Result<Int?, DecodeError>

A mapping, or nothing at all, which is an empty map. Its keys are nodes, read as the key type asks.

fn hasNext

var fn hasNext(): Result<Bool, DecodeError>

Not documented.

fn record

var fn record(typeName: String): Result<Void, DecodeError>

A mapping's entries are the record's fields. Nothing at all is a record of defaults, and any other node a wrapper: the one value the record holds. A local tag has to stand for this type.

fn variant

var fn variant(typeName: String): Result<String, DecodeError>

A case: a local tag that tags names for one (!circle \{radius: 2\}), a plain scalar that is the case's name, or a mapping of one entry whose key is the name and whose value holds the fields (Circle: \{radius: 2\}).

fn field

var fn field(name: String): Result<Bool, DecodeError>

Not documented.

fn finish

var fn finish(): Result<Void, DecodeError>

Not documented.