Skip to content

CborBuilder

const CborBuilder: object

Defined in: ootle/src/helpers/cbor-builder.ts:298

Entry point for building struct, enum, list and map arguments. Builders nest: pass one to another’s field/add, and call finish() on the outermost only.

const arg = CborBuilder.struct()
.field(0, "name")
.field(1, CborBuilder.array([1, 2, 3]))
.field(2, CborBuilder.variant(1).field(0, true))
.finish();

readonly array: (items) => CborArrayBuilder

A Vec or tuple.

CborValue[] = []

CborArrayBuilder

readonly map: () => CborMapBuilder

A BTreeMap or HashMap. Entries are written in a fixed order, whatever order they were added in.

CborMapBuilder

readonly struct: () => CborStructBuilder

A Rust struct: fields are set by their #[n(i)] index.

CborStructBuilder

readonly variant: (index) => CborVariantBuilder

A Rust enum value: index is the variant’s #[n(i)]. An enum marked #[cbor(index_only)] is written as the bare index instead: pass the number itself.

number

CborVariantBuilder