Turns a Record<K, V>
into a discriminated union { __kind: K, ...V }
.
Enum Variant Kinds
Defines a type supported by beet.
Alias for uint8Array.
Maps collections beet exports to metadata which describes in which package it is defined as well as which TypeScript type is used to represent the deserialized value in JavaScript.
Maps composite beet exports to metadata which describes in which package it is defined as well as which TypeScript type is used to represent the deserialized value in JavaScript.
Maps composite beet exports to metadata which describes in which package it is defined as well as which TypeScript type is used to represent the deserialized value in JavaScript.
Maps primitive beet exports to metadata which describes in which package it is defined as well as which TypeScript type is used to represent the deserialized value in JavaScript.
Maps string beet exports to metadata which describes in which package it is defined as well as which TypeScript type is used to represent the deserialized value in JavaScript.
Maps all Beet de/serializers to metadata which describes in which package it is defined as well as which TypeScript type is used to represent the deserialized value in JavaScript.
Maps collections beet exports to metadata which describes in which package it is defined as well as which TypeScript type is used to represent the deserialized value in JavaScript.
Base Beet type.
Describes the type of data that is de/serialized and serves for debugging and diagnostics only.
Specifies a field that is part of the type {@link T} along with its De/Serializer.
the type of which the field is a member
Specifies the read/write methods that a beet may implement.
Number of bytes that are used to store the value in a {@link Buffer}
Reads the data in the provided buffer and deserializes it into a value of type {@link T}.
containing the data to deserialize
at which to start reading from the buffer
deserialized instance of type {@link T}.
Writes the value of type {@link T} to the provided buffer.
the buffer to write the serialized value to
at which to start writing into the buffer
to write
Implemented by ElementCollectionFixedSizeBeets to expose information about collection elements and collection size.
For arrays and strings this indicates the byte size of each element.
For arrays and strings this indicates the byte size of the number that indicates its length.
Thus the size of each element for arrays is (this.byteSize - lenPrefixSize) / elementCount
For arrays and strings this indicates the amount of elements/chars.
Beet for Collections
Template for De/Serializer which has a dynamic size, meaning its Buffer size when serialized changes depending on the data it contains.
It is fixable in the sense that a FixedSizeBeet can be derived from it by providing either the value or serialized data for the particular instance.
is the data type which is being de/serialized
is the value type passed to the write which includes all
properties needed to produce {@link T}, defaults to Partial<T>
Specifies a field that is part of the type {@link T} along with its De/Serializer.
the type of which the field is a member
Template for De/Serializer which is of fixed size, meaning its Buffer size when serialized doesn't change depending on the data it contains.
is the data type which is being de/serialized
is the value type passed to the write which includes all
properties needed to produce {@link T}, defaults to Partial<T>
Scalar Beet
Represents a number that can be larger than the builtin Integer type. It is backed by BN for large numbers.
Converts the provided beet into a {@link FixedBeet} unless it already is. The sizes for FixableBeets are determined from the provided data.
to convert
containing serialized data that the fixed beet needs to process
at which the data for the beet starts
Converts the provided beet into a {@link FixedBeet} unless it already is. The sizes for FixableBeets are determined from the provided value.
to convert
value that the fixed beet needs to process
A De/Serializer for {@link Uint8Array}s that just copies/reads the array bytes to/from the provided buffer.
De/Serializes a UTF8 string of any size.
Wraps an array De/Serializer with with elements of type {@link T} which do not all have the same size.
type of elements held in the array
the De/Serializer for the element types
De/Serializes an array with a specific number of elements of type {@link T} which do not all have the same size.
type of elements held in the array
the De/Serializers for the element types
size of all elements in the array combined
A De/Serializer for raw {@link Buffer}s that just copies/reads the buffer bytes to/from the provided buffer.
the byte size of the buffer to de/serialize
De/Serializes a tuple with all fixed size tuple elements . Since each tuple element can be of a different type not much type safety can be provided here.
the De/Serializer for each tuple element type
A De/Serializer for {@link Uint8Array}s of known size that just copies/reads the array bytes to/from the provided buffer.
De/Serializes a UTF8 string of a particular size.
the number of bytes of the string
De/Serializes a tuple which contains some non-fixed size tuple elements.
Since each tuple element can be of a different type not much type safety can be provided here.
the De/Serializer for each tuple element type
De/Serializes an array with a specific number of elements of type {@link T} which all have the same size.
type of elements held in the array
the De/Serializer for the element type
the number of elements in the array
if true
a 4 byte number indicating the size of the array
will be included before serialized array data
Represents an Enum type which contains fixed size data and whose data is uniform across all variants.
the enum variant, i.e. Color.Red
the data value, i.e. '#f00'
De/Serializes an Option of type {@link T} represented by COption.
The de/serialized type is prefixed with 1
if the inner value is present
and with 0
if not.
This matches the COption
type borsh representation.
inner option type
the De/Serializer for the inner type
De/Serializes Some
case of an Option of type {@link T} represented by
COption.
The de/serialized type is prefixed with 1
.
This matches the COption::Some
type borsh representation.
inner option type
the De/Serializer for the inner type
De/serializes Data Enums. They are represented as a discriminated unions in TypeScript.
NOTE: only structs, i.e. BeetArgsStruct and FixableBeetArgsStruct are supported as the data of each enum variant.
type Simple = {
First: { n1: number }
Second: { n2: number }
}
const beet = dataEnum<Simple>([
['First', new BeetArgsStruct<Simple['First']>([['n1', u32]])],
['Second', new BeetArgsStruct<Simple['Second']>([['n2', u32]])],
])
an array of DataEnumBeets each a tuple of [ kind, data ]
De/serializer for enums with up to 255 less variants which have no data.
type of enum to process, i.e. Color or Direction
De/Serializes an Enum that contains a type of data, i.e. a {@link Struct}. The main difference to a Rust enum is that the type of data has to be the same for all enum variants.
the De/Serializer for the data type
Represents the Rust Option type {@link T}.
inner option type
De/Serializes None
case of an Option of type {@link T} represented by
COption.
The de/serialized type is prefixed with 0
.
This matches the COption::None
type borsh representation.
inner option type
De/Serializer booleans aka bool
.
De/Serializer for 128-bit signed integers aka i128
which serializes to a JavaScript
BigNum via BN.
De/Serializer 16-bit signed integers aka i16
.
De/Serializer for 256-bit signed integers aka i256
which serializes to a JavaScript
BigNum via BN.
De/Serializer 32-bit signed integers aka i32
.
De/Serializer for 512-bit signed integers aka i512
which serializes to a JavaScript
BigNum via BN.
De/Serializer for 64-bit signed integers aka i64
which serializes to a JavaScript
BigNum via BN.
De/Serializer 8-bit signed integers aka i8
.
De/Serializer for 128-bit unsigned integers aka u128
which serializes to a JavaScript
BigNum via BN.
De/Serializer 16-bit unsigned integers aka u16
.
De/Serializer for 256-bit unsigned integers aka u256
which serializes to a JavaScript
BigNum via BN.
De/Serializer for 32-bit unsigned integers aka u32
.
De/Serializer for 512-bit unsigned integers aka u512
which serializes to a JavaScript
BigNum via BN.
De/Serializer for 64-bit unsigned integers aka u64
which serializes to a JavaScript
BigNum via BN.
De/Serializer for 8-bit unsigned integers aka u8
.
Generated using TypeDoc
Turns a
Record<K, Beet<V>>
into a discriminated union{ __kind: K, dataBeet: Beet<V> }
.