Scale JS / @scale-codec/core
Module: @scale-codec/core
Core SCALE library with tools to encode to and decode SCALE binaries. It includes implementations for primitive types as well as for complex types.
Table of contents
Namespaces
Classes
Interfaces
Type Aliases
- BigIntTypes
- Decode
- Encode
- EnumDecoders
- EnumEncoders
- EnumOf
- EnumRecord
- Enumerate
- IntTypes
- RustOption
- RustResult
- StructDecoders
- StructEncoders
- TupleDecoders
- TupleEncoders
- VariantAny
- VariantToFactoryArgs
Functions
- countPositiveBigIntEffectiveBytes
- createArrayDecoder
- createArrayEncoder
- createBigIntDecoder
- createBigIntEncoder
- createEnumDecoder
- createEnumEncoder
- createIntDecoder
- createIntEncoder
- createMapDecoder
- createMapEncoder
- createOptionDecoder
- createOptionEncoder
- createResultDecoder
- createResultEncoder
- createSetDecoder
- createSetEncoder
- createStructDecoder
- createStructEncoder
- createTupleDecoder
- createTupleEncoder
- createUint8ArrayDecoder
- createUint8ArrayEncoder
- createVecDecoder
- createVecEncoder
- decodeArray
- decodeBigInt
- decodeBigIntVarious
- decodeBool
- decodeCompact
- decodeEnum
- decodeI128
- decodeI16
- decodeI32
- decodeI64
- decodeI8
- decodeInt
- decodeMap
- decodeOptionBool
- decodeSet
- decodeStr
- decodeStruct
- decodeTuple
- decodeU128
- decodeU16
- decodeU32
- decodeU64
- decodeU8
- decodeUint8Array
- decodeUint8Vec
- decodeUnit
- decodeVec
- encodeArray
- encodeArraySizeHint
- encodeBigInt
- encodeBool
- encodeCompact
- encodeEnum
- encodeEnumSizeHint
- encodeFactory
- encodeI128
- encodeI16
- encodeI32
- encodeI64
- encodeI8
- encodeInt
- encodeMap
- encodeMapSizeHint
- encodeOptionBool
- encodePositiveBigIntInto
- encodeSet
- encodeSetSizeHint
- encodeStr
- encodeStruct
- encodeStructSizeHint
- encodeTuple
- encodeTupleSizeHint
- encodeU128
- encodeU16
- encodeU32
- encodeU64
- encodeU8
- encodeUint8Array
- encodeUint8Vec
- encodeUnit
- encodeVec
- encodeVecSizeHint
- variant
Type Aliases
BigIntTypes
Ƭ BigIntTypes: IntTypes
| `${"i" | "u"}${64 | 128 | 256 | 512}`
Set of integer types that are supported by codec for bigint
Defined in
packages/core/src/codecs/int.ts:13
Decode
Ƭ Decode<T
>: (walker
: Walker
) => T
Type parameters
Name |
---|
T |
Type declaration
▸ (walker
): T
Parameters
Name | Type |
---|---|
walker | Walker |
Returns
T
Defined in
Encode
Ƭ Encode<T
>: Object
Type parameters
Name |
---|
T |
Call signature
▸ (value
, walker
): void
Parameters
Name | Type |
---|---|
value | T |
walker | Walker |
Returns
void
Type declaration
Name | Type |
---|---|
sizeHint | (value : T ) => number |
Defined in
EnumDecoders
Ƭ EnumDecoders<E
>: { [D in number]: { [tag in keyof E]: E[tag] extends [infer C] ? DecodeTuple<tag & string, C> : tag & string }[keyof E] }
Type parameters
Name | Type |
---|---|
E | extends EnumRecord |
Defined in
packages/core/src/codecs/enum.ts:13
EnumEncoders
Ƭ EnumEncoders<E
>: { [tag in keyof E]: E[tag] extends [infer C] ? EncodeTuple<C> : number }
Type parameters
Name | Type |
---|---|
E | extends EnumRecord |
Defined in
packages/core/src/codecs/enum.ts:9
EnumOf
Ƭ EnumOf<V
>: V
extends Variant
<infer E, any
, any
> ? E
: never
Type parameters
Name | Type |
---|---|
V | extends VariantAny |
Defined in
EnumRecord
Ƭ EnumRecord: Record
<string
, [] | [any
]>
Defined in
Enumerate
Ƭ Enumerate<E
>: { [Tag in keyof E]: E[Tag] extends infer Content extends [] | [any] ? Variant<E, Tag & string, Content> : never }[keyof E
]
Type parameters
Name | Type |
---|---|
E | extends EnumRecord |
Defined in
IntTypes
Ƭ IntTypes: `${"i" | "u"}${8 | 16 | 32}`
Set of integer types that are supported by codec for number
Defined in
packages/core/src/codecs/int.ts:8
RustOption
Ƭ RustOption<T
>: Enumerate
<{ None
: [] ; Some
: [T
] }>
Rust's Option<T>
analog
Example
const maybeString: RustOption<string> = variant('None')
Type parameters
Name |
---|
T |
Defined in
RustResult
Ƭ RustResult<Ok
, Err
>: Enumerate
<{ Err
: [Err
] ; Ok
: [Ok
] }>
Rust's Result<Ok, Err>
analog
Example
const file: RustResult<string, Error> = variant('Ok', 'file contents')
Type parameters
Name |
---|
Ok |
Err |
Defined in
StructDecoders
Ƭ StructDecoders<T
>: { [K in keyof T]: [K, Decode<T[K]>] }[keyof T
][]
Type parameters
Name |
---|
T |
Defined in
packages/core/src/codecs/struct.ts:6
StructEncoders
Ƭ StructEncoders<T
>: { [K in keyof T]: [K, Encode<T[K]>] }[keyof T
][]
Type parameters
Name |
---|
T |
Defined in
packages/core/src/codecs/struct.ts:4
TupleDecoders
Ƭ TupleDecoders<Tuple
>: Tuple
extends [infer Head, ...(infer Tail)] ? [Decode
<Head
>, ...TupleDecoders<Tail>] : []
Type parameters
Name | Type |
---|---|
Tuple | extends any [] |
Defined in
packages/core/src/codecs/tuple.ts:8
TupleEncoders
Ƭ TupleEncoders<Tuple
>: Tuple
extends [infer Head, ...(infer Tail)] ? [Encode
<Head
>, ...TupleEncoders<Tail>] : []
Type parameters
Name | Type |
---|---|
Tuple | extends any [] |
Defined in
packages/core/src/codecs/tuple.ts:4
VariantAny
Ƭ VariantAny: Variant
<any
, any
, any
>
Defined in
VariantToFactoryArgs
Ƭ VariantToFactoryArgs<V
>: V
extends Variant
<any
, infer Tag, infer Content> ? Content
extends [infer C] ? [tag: Tag, content: C] : [tag: Tag] : never
Type parameters
Name | Type |
---|---|
V | extends VariantAny |
Defined in
Functions
countPositiveBigIntEffectiveBytes
▸ countPositiveBigIntEffectiveBytes(positiveNum
): number
Parameters
Name | Type |
---|---|
positiveNum | bigint |
Returns
number
Defined in
packages/core/src/codecs/int.ts:172
createArrayDecoder
▸ createArrayDecoder<T
>(decodeItem
, len
): Decode
<T
[]>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
decodeItem | Decode <T > |
len | number |
Returns
Decode
<T
[]>
Defined in
packages/core/src/codecs/array.ts:40
createArrayEncoder
▸ createArrayEncoder<T
>(encodeItem
, len
): Encode
<T
[]>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
encodeItem | Encode <T > |
len | number |
Returns
Encode
<T
[]>
Defined in
packages/core/src/codecs/array.ts:25
createBigIntDecoder
▸ createBigIntDecoder(ty
): Decode
<bigint
>
Parameters
Name | Type |
---|---|
ty | BigIntTypes |
Returns
Decode
<bigint
>
Defined in
packages/core/src/codecs/int.ts:265
createBigIntEncoder
▸ createBigIntEncoder(ty
): Encode
<bigint
>
Parameters
Name | Type |
---|---|
ty | BigIntTypes |
Returns
Encode
<bigint
>
Defined in
packages/core/src/codecs/int.ts:261
createEnumDecoder
▸ createEnumDecoder<V
>(decoders
): Decode
<V
>
Type parameters
Name | Type |
---|---|
V | extends Variant <any , any , any , V > |
Parameters
Name | Type |
---|---|
decoders | EnumDecoders <EnumOf <V >> |
Returns
Decode
<V
>
Defined in
packages/core/src/codecs/enum.ts:111
createEnumEncoder
▸ createEnumEncoder<V
>(encoders
): Encode
<V
>
Type parameters
Name | Type |
---|---|
V | extends Variant <any , any , any , V > |
Parameters
Name | Type |
---|---|
encoders | EnumEncoders <EnumOf <V >> |
Returns
Encode
<V
>
Defined in
packages/core/src/codecs/enum.ts:77
createIntDecoder
▸ createIntDecoder(ty
): Decode
<number
>
Parameters
Name | Type |
---|---|
ty | "i16" | "i8" | "i32" | "u16" | "u8" | "u32" |
Returns
Decode
<number
>
Defined in
packages/core/src/codecs/int.ts:257
createIntEncoder
▸ createIntEncoder(ty
): Encode
<number
>
Parameters
Name | Type |
---|---|
ty | "i16" | "i8" | "i32" | "u16" | "u8" | "u32" |
Returns
Encode
<number
>
Defined in
packages/core/src/codecs/int.ts:253
createMapDecoder
▸ createMapDecoder<K
, V
>(decodeKey
, decodeValue
): Decode
<Map
<K
, V
>>
Type parameters
Name |
---|
K |
V |
Parameters
Name | Type |
---|---|
decodeKey | Decode <K > |
decodeValue | Decode <V > |
Returns
Decode
<Map
<K
, V
>>
Defined in
packages/core/src/codecs/map.ts:45
createMapEncoder
▸ createMapEncoder<K
, V
>(encodeKey
, encodeValue
): Encode
<Map
<K
, V
>>
Type parameters
Name |
---|
K |
V |
Parameters
Name | Type |
---|---|
encodeKey | Encode <K > |
encodeValue | Encode <V > |
Returns
Encode
<Map
<K
, V
>>
Defined in
packages/core/src/codecs/map.ts:38
createOptionDecoder
▸ createOptionDecoder<T
>(decodeSome
): Decode
<RustOption
<T
>>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
decodeSome | Decode <T > |
Returns
Decode
<RustOption
<T
>>
Defined in
packages/core/src/codecs/enum.ts:122
createOptionEncoder
▸ createOptionEncoder<T
>(encodeSome
): Encode
<RustOption
<T
>>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
encodeSome | Encode <T > |
Returns
Encode
<RustOption
<T
>>
Defined in
packages/core/src/codecs/enum.ts:115
createResultDecoder
▸ createResultDecoder<Ok
, Err
>(decodeOk
, decodeErr
): Decode
<RustResult
<Ok
, Err
>>
Type parameters
Name |
---|
Ok |
Err |
Parameters
Name | Type |
---|---|
decodeOk | Decode <Ok > |
decodeErr | Decode <Err > |
Returns
Decode
<RustResult
<Ok
, Err
>>
Defined in
packages/core/src/codecs/enum.ts:139
createResultEncoder
▸ createResultEncoder<Ok
, Err
>(encodeOk
, encodeErr
): Encode
<RustResult
<Ok
, Err
>>
Type parameters
Name |
---|
Ok |
Err |
Parameters
Name | Type |
---|---|
encodeOk | Encode <Ok > |
encodeErr | Encode <Err > |
Returns
Encode
<RustResult
<Ok
, Err
>>
Defined in
packages/core/src/codecs/enum.ts:129
createSetDecoder
▸ createSetDecoder<T
>(decodeItem
): Decode
<Set
<T
>>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
decodeItem | Decode <T > |
Returns
Decode
<Set
<T
>>
Defined in
packages/core/src/codecs/set.ts:36
createSetEncoder
▸ createSetEncoder<T
>(encodeItem
): Encode
<Set
<T
>>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
encodeItem | Encode <T > |
Returns
Encode
<Set
<T
>>
Defined in
packages/core/src/codecs/set.ts:29
createStructDecoder
▸ createStructDecoder<T
>(decoders
): Decode
<T
>
Type parameters
Name | Type |
---|---|
T | extends Object |
Parameters
Name | Type |
---|---|
decoders | StructDecoders <T > |
Returns
Decode
<T
>
Defined in
packages/core/src/codecs/struct.ts:40
createStructEncoder
▸ createStructEncoder<T
>(encoders
): Encode
<T
>
Type parameters
Name | Type |
---|---|
T | extends Object |
Parameters
Name | Type |
---|---|
encoders | StructEncoders <T > |
Returns
Encode
<T
>
Defined in
packages/core/src/codecs/struct.ts:24
createTupleDecoder
▸ createTupleDecoder<T
>(decoders
): Decode
<T
>
Type parameters
Name | Type |
---|---|
T | extends any [] |
Parameters
Name | Type |
---|---|
decoders | TupleDecoders <T > |
Returns
Decode
<T
>
Defined in
packages/core/src/codecs/tuple.ts:44
createTupleEncoder
▸ createTupleEncoder<T
>(encoders
): Encode
<T
>
Type parameters
Name | Type |
---|---|
T | extends any [] |
Parameters
Name | Type |
---|---|
encoders | TupleEncoders <T > |
Returns
Encode
<T
>
Defined in
packages/core/src/codecs/tuple.ts:37
createUint8ArrayDecoder
▸ createUint8ArrayDecoder(len
): Decode
<Uint8Array
>
Parameters
Name | Type |
---|---|
len | number |
Returns
Decode
<Uint8Array
>
Defined in
packages/core/src/codecs/array.ts:79
createUint8ArrayEncoder
▸ createUint8ArrayEncoder(len
): Encode
<Uint8Array
>
Parameters
Name | Type |
---|---|
len | number |
Returns
Encode
<Uint8Array
>
Defined in
packages/core/src/codecs/array.ts:53
createVecDecoder
▸ createVecDecoder<T
>(decodeItem
): Decode
<T
[]>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
decodeItem | Decode <T > |
Returns
Decode
<T
[]>
Defined in
packages/core/src/codecs/vec.ts:33
createVecEncoder
▸ createVecEncoder<T
>(encodeItem
): Encode
<T
[]>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
encodeItem | Encode <T > |
Returns
Encode
<T
[]>
Defined in
packages/core/src/codecs/vec.ts:21
decodeArray
▸ decodeArray<T
>(walker
, decodeItem
, len
): T
[]
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
walker | Walker |
decodeItem | Decode <T > |
len | number |
Returns
T
[]
Defined in
packages/core/src/codecs/array.ts:32
decodeBigInt
▸ decodeBigInt(walker
, ty
): bigint
Decodes bigint
in Little-Endian
Parameters
Name | Type |
---|---|
walker | Walker |
ty | BigIntTypes |
Returns
bigint
Defined in
packages/core/src/codecs/int.ts:238
decodeBigIntVarious
▸ decodeBigIntVarious(walker
, bytes
, signed
): bigint
Decodes bigint
in Little-Endian. It is like decodeBigInt but is not binded to strict bytes count (1, 2, 4, 8, 16 etc)
Remarks
Does not mutate walker's offset!
Parameters
Name | Type |
---|---|
walker | Walker |
bytes | number |
signed | boolean |
Returns
bigint
Defined in
packages/core/src/codecs/int.ts:216
decodeBool
▸ decodeBool(walker
): boolean
Parameters
Name | Type |
---|---|
walker | Walker |
Returns
boolean
Defined in
decodeCompact
▸ decodeCompact(walker
): bigint
Decodes compact-encoded integer
Parameters
Name | Type |
---|---|
walker | Walker |
Returns
bigint
Defined in
packages/core/src/codecs/compact.ts:17
decodeEnum
▸ decodeEnum<V
>(walker
, decoders
): V
Type parameters
Name | Type |
---|---|
V | extends Variant <any , any , any , V > |
Parameters
Name | Type |
---|---|
walker | Walker |
decoders | EnumDecoders <EnumOf <V >> |
Returns
V
Defined in
packages/core/src/codecs/enum.ts:97
decodeI128
▸ decodeI128(walker
): bigint
Parameters
Name | Type |
---|---|
walker | Walker |
Returns
bigint
Defined in
decodeI16
▸ decodeI16(walker
): number
Parameters
Name | Type |
---|---|
walker | Walker |
Returns
number
Defined in
decodeI32
▸ decodeI32(walker
): number
Parameters
Name | Type |
---|---|
walker | Walker |
Returns
number
Defined in
decodeI64
▸ decodeI64(walker
): bigint
Parameters
Name | Type |
---|---|
walker | Walker |
Returns
bigint
Defined in
decodeI8
▸ decodeI8(walker
): number
Parameters
Name | Type |
---|---|
walker | Walker |
Returns
number
Defined in
decodeInt
▸ decodeInt(walker
, ty
): number
Decodes signed/unsigned 8/16/32 bits integers in Little-Endian
Parameters
Name | Type |
---|---|
walker | Walker |
ty | "i16" | "i8" | "i32" | "u16" | "u8" | "u32" |
Returns
number
Defined in
packages/core/src/codecs/int.ts:89
decodeMap
▸ decodeMap<K
, V
>(walker
, decodeKey
, decodeValue
): Map
<K
, V
>
Type parameters
Name |
---|
K |
V |
Parameters
Name | Type |
---|---|
walker | Walker |
decodeKey | Decode <K > |
decodeValue | Decode <V > |
Returns
Map
<K
, V
>
Defined in
packages/core/src/codecs/map.ts:29
decodeOptionBool
▸ decodeOptionBool(walker
): RustOption
<boolean
>
Special decoder for OptionBool
type from Rust's parity_scale_codec
Parameters
Name | Type |
---|---|
walker | Walker |
Returns
RustOption
<boolean
>
Defined in
decodeSet
▸ decodeSet<T
>(walker
, decodeItem
): Set
<T
>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
walker | Walker |
decodeItem | Decode <T > |
Returns
Set
<T
>
Defined in
packages/core/src/codecs/set.ts:20
decodeStr
▸ decodeStr(walker
): string
Parameters
Name | Type |
---|---|
walker | Walker |
Returns
string
Defined in
packages/core/src/codecs/str.ts:12
decodeStruct
▸ decodeStruct<T
>(walker
, decoders
): T
Type parameters
Name | Type |
---|---|
T | extends Object |
Parameters
Name | Type |
---|---|
walker | Walker |
decoders | StructDecoders <T > |
Returns
T
Defined in
packages/core/src/codecs/struct.ts:31
decodeTuple
▸ decodeTuple<T
>(walker
, decoders
): T
Type parameters
Name | Type |
---|---|
T | extends any [] |
Parameters
Name | Type |
---|---|
walker | Walker |
decoders | TupleDecoders <T > |
Returns
T
Defined in
packages/core/src/codecs/tuple.ts:27
decodeU128
▸ decodeU128(walker
): bigint
Parameters
Name | Type |
---|---|
walker | Walker |
Returns
bigint
Defined in
decodeU16
▸ decodeU16(walker
): number
Parameters
Name | Type |
---|---|
walker | Walker |
Returns
number
Defined in
decodeU32
▸ decodeU32(walker
): number
Parameters
Name | Type |
---|---|
walker | Walker |
Returns
number
Defined in
decodeU64
▸ decodeU64(walker
): bigint
Parameters
Name | Type |
---|---|
walker | Walker |
Returns
bigint
Defined in
decodeU8
▸ decodeU8(walker
): number
Parameters
Name | Type |
---|---|
walker | Walker |
Returns
number
Defined in
decodeUint8Array
▸ decodeUint8Array(walker
, len
): Uint8Array
decode [u8; x]
array directly into the native Uint8Array
Parameters
Name | Type |
---|---|
walker | Walker |
len | number |
Returns
Uint8Array
Defined in
packages/core/src/codecs/array.ts:66
decodeUint8Vec
▸ decodeUint8Vec(walker
): Uint8Array
Parameters
Name | Type |
---|---|
walker | Walker |
Returns
Uint8Array
Defined in
decodeUnit
▸ decodeUnit(walker
): null
Decoder to handle unit type (i.e. ()
)
Parameters
Name | Type |
---|---|
walker | Walker |
Returns
null
Defined in
decodeVec
▸ decodeVec<T
>(walker
, decodeItem
): T
[]
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
walker | Walker |
decodeItem | Decode <T > |
Returns
T
[]
Defined in
packages/core/src/codecs/vec.ts:28
encodeArray
▸ encodeArray<T
>(arr
, encodeItem
, len
, walker
): void
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
arr | T [] |
encodeItem | Encode <T > |
len | number |
walker | Walker |
Returns
void
Defined in
packages/core/src/codecs/array.ts:5
encodeArraySizeHint
▸ encodeArraySizeHint<T
>(arr
, encodeItem
, len
): number
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
arr | T [] |
encodeItem | Encode <T > |
len | number |
Returns
number
Defined in
packages/core/src/codecs/array.ts:14
encodeBigInt
▸ encodeBigInt(bi
, ty
, walker
): void
Encodes bigint
in Little-Endian
Parameters
Name | Type |
---|---|
bi | bigint |
ty | BigIntTypes |
walker | Walker |
Returns
void
Defined in
packages/core/src/codecs/int.ts:185
encodeBool
▸ encodeBool(value
, walker
): void
Parameters
Name | Type |
---|---|
value | boolean |
walker | Walker |
Returns
void
Defined in
encodeCompact
▸ encodeCompact(value
, walker
): void
Parameters
Name | Type |
---|---|
value | number | bigint |
walker | Walker |
Returns
void
Defined in
encodeEnum
▸ encodeEnum<V
>(value
, encoders
, walker
): void
Type parameters
Name | Type |
---|---|
V | extends Variant <any , any , any , V > |
Parameters
Name | Type |
---|---|
value | V |
encoders | EnumEncoders <EnumOf <V >> |
walker | Walker |
Returns
void
Defined in
packages/core/src/codecs/enum.ts:48
encodeEnumSizeHint
▸ encodeEnumSizeHint<V
>(value
, encoders
): number
Type parameters
Name | Type |
---|---|
V | extends Variant <any , any , any , V > |
Parameters
Name | Type |
---|---|
value | V |
encoders | EnumEncoders <EnumOf <V >> |
Returns
number
Defined in
packages/core/src/codecs/enum.ts:59
encodeFactory
▸ encodeFactory<T
>(fn
, sizeHint
): Encode
<T
>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
fn | (value : T , walker : Walker ) => void |
sizeHint | (value : T ) => number |
Returns
Encode
<T
>
Defined in
encodeI128
▸ encodeI128(value
, walker
): void
Parameters
Name | Type |
---|---|
value | bigint |
walker | Walker |
Returns
void
Defined in
encodeI16
▸ encodeI16(value
, walker
): void
Parameters
Name | Type |
---|---|
value | number |
walker | Walker |
Returns
void
Defined in
encodeI32
▸ encodeI32(value
, walker
): void
Parameters
Name | Type |
---|---|
value | number |
walker | Walker |
Returns
void
Defined in
encodeI64
▸ encodeI64(value
, walker
): void
Parameters
Name | Type |
---|---|
value | bigint |
walker | Walker |
Returns
void
Defined in
encodeI8
▸ encodeI8(value
, walker
): void
Parameters
Name | Type |
---|---|
value | number |
walker | Walker |
Returns
void
Defined in
encodeInt
▸ encodeInt(value
, ty
, walker
): void
Encodes signed/unsigned 8/16/32 bits integers in Little-Endian
Parameters
Name | Type |
---|---|
value | number |
ty | "i16" | "i8" | "i32" | "u16" | "u8" | "u32" |
walker | Walker |
Returns
void
Defined in
packages/core/src/codecs/int.ts:56
encodeMap
▸ encodeMap<K
, V
>(map
, encodeKey
, encodeValue
, walker
): void
Type parameters
Name |
---|
K |
V |
Parameters
Name | Type |
---|---|
map | Map <K , V > |
encodeKey | Encode <K > |
encodeValue | Encode <V > |
walker | Walker |
Returns
void
Defined in
packages/core/src/codecs/map.ts:6
encodeMapSizeHint
▸ encodeMapSizeHint<K
, V
>(map
, encodeKey
, encodeValue
): number
Type parameters
Name |
---|
K |
V |
Parameters
Name | Type |
---|---|
map | Map <K , V > |
encodeKey | Encode <K > |
encodeValue | Encode <V > |
Returns
number
Defined in
packages/core/src/codecs/map.ts:14
encodeOptionBool
▸ encodeOptionBool(value
, walker
): void
Special encoder for OptionBool
type from Rust's parity_scale_codec
Parameters
Name | Type |
---|---|
value | RustOption <boolean > |
walker | Walker |
Returns
void
Defined in
encodePositiveBigIntInto
▸ encodePositiveBigIntInto(positiveNum
, mutSlice
, offset
, bytesLimit
): number
Parameters
Name | Type |
---|---|
positiveNum | bigint |
mutSlice | Uint8Array |
offset | number |
bytesLimit | number |
Returns
number
Defined in
packages/core/src/codecs/int.ts:152
encodeSet
▸ encodeSet<T
>(set
, encodeItem
, walker
): void
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
set | Set <T > |
encodeItem | Encode <T > |
walker | Walker |
Returns
void
Defined in
packages/core/src/codecs/set.ts:5
encodeSetSizeHint
▸ encodeSetSizeHint<T
>(set
, encodeItem
): number
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
set | Set <T > |
encodeItem | Encode <T > |
Returns
number
Defined in
packages/core/src/codecs/set.ts:12
encodeStr
▸ encodeStr(value
, walker
): void
Parameters
Name | Type |
---|---|
value | string |
walker | Walker |
Returns
void
Defined in
encodeStruct
▸ encodeStruct<T
>(struct
, encoders
, walker
): void
Type parameters
Name | Type |
---|---|
T | extends Object |
Parameters
Name | Type |
---|---|
struct | T |
encoders | StructEncoders <T > |
walker | Walker |
Returns
void
Defined in
packages/core/src/codecs/struct.ts:8
encodeStructSizeHint
▸ encodeStructSizeHint<T
>(struct
, encoders
): number
Type parameters
Name | Type |
---|---|
T | extends Object |
Parameters
Name | Type |
---|---|
struct | T |
encoders | StructEncoders <T > |
Returns
number
Defined in
packages/core/src/codecs/struct.ts:15
encodeTuple
▸ encodeTuple<T
>(tuple
, encoders
, walker
): void
Type parameters
Name | Type |
---|---|
T | extends any [] |
Parameters
Name | Type |
---|---|
tuple | T |
encoders | TupleEncoders <T > |
walker | Walker |
Returns
void
Defined in
packages/core/src/codecs/tuple.ts:12
encodeTupleSizeHint
▸ encodeTupleSizeHint<T
>(tuple
, encoders
): number
Type parameters
Name | Type |
---|---|
T | extends any [] |
Parameters
Name | Type |
---|---|
tuple | T |
encoders | TupleEncoders <T > |
Returns
number
Defined in
packages/core/src/codecs/tuple.ts:17
encodeU128
▸ encodeU128(value
, walker
): void
Parameters
Name | Type |
---|---|
value | bigint |
walker | Walker |
Returns
void
Defined in
encodeU16
▸ encodeU16(value
, walker
): void
Parameters
Name | Type |
---|---|
value | number |
walker | Walker |
Returns
void
Defined in
encodeU32
▸ encodeU32(value
, walker
): void
Parameters
Name | Type |
---|---|
value | number |
walker | Walker |
Returns
void
Defined in
encodeU64
▸ encodeU64(value
, walker
): void
Parameters
Name | Type |
---|---|
value | bigint |
walker | Walker |
Returns
void
Defined in
encodeU8
▸ encodeU8(value
, walker
): void
Parameters
Name | Type |
---|---|
value | number |
walker | Walker |
Returns
void
Defined in
encodeUint8Array
▸ encodeUint8Array(value
, len
, walker
): void
Encode to [u8; x]
Rust's array directly from the native Uint8Array
Parameters
Name | Type |
---|---|
value | Uint8Array |
len | number |
walker | Walker |
Returns
void
Defined in
packages/core/src/codecs/array.ts:47
encodeUint8Vec
▸ encodeUint8Vec(value
, walker
): void
Parameters
Name | Type |
---|---|
value | Uint8Array |
walker | Walker |
Returns
void
Defined in
encodeUnit
▸ encodeUnit(value
, walker
): void
Encoder to handle unit type (i.e. ()
)
Parameters
Name | Type |
---|---|
value | null |
walker | Walker |
Returns
void
Defined in
encodeVec
▸ encodeVec<T
>(vec
, encodeItem
, walker
): void
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
vec | T [] |
encodeItem | Encode <T > |
walker | Walker |
Returns
void
Defined in
packages/core/src/codecs/vec.ts:6
encodeVecSizeHint
▸ encodeVecSizeHint<T
>(vec
, encodeItem
): number
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
vec | T [] |
encodeItem | Encode <T > |
Returns
number
Defined in
packages/core/src/codecs/vec.ts:13
variant
▸ variant<V
>(...args
): V
Type parameters
Name | Type |
---|---|
V | extends Variant <any , any , any , V > |
Parameters
Name | Type |
---|---|
...args | VariantToFactoryArgs <V > |
Returns
V
Defined in
▸ variant<E
>(...args
): Enumerate
<E
>
Type parameters
Name | Type |
---|---|
E | extends EnumRecord |
Parameters
Name | Type |
---|---|
...args | VariantToFactoryArgs <Enumerate <E >> |
Returns
Enumerate
<E
>