Scale JS / @scale-codec/definition-runtime
Module: @scale-codec/definition-runtime
Runtime for the output of @scale-codec/definition-compiler
Remarks
Reexports the whole core library and defines codecs for STD types.
Table of contents
Namespaces
Classes
Interfaces
- Codec
- CodecTracker
- EnumBox
- FormatWalkerStepParams
- LoggerConfig
- TrackValueInspectable
- Variant
- VariantFactoryFn
- Walker
Type Aliases
- BigIntTypes
- Bool
- CodecAny
- CodecArray
- CodecEnum
- CodecMap
- CodecSet
- CodecStruct
- CodecValueDecoded
- CodecValueEncodable
- Compact
- Decode
- DefineOpaque
- Encode
- EnumBoxToFactory
- EnumCodecSchema
- EnumDecoders
- EnumEncoders
- EnumOf
- EnumRecord
- Enumerate
- FilterStringKeys
- I128
- I16
- I32
- I64
- I8
- IntTypes
- RefineDecodeLocFn
- RustOption
- RustResult
- Str
- StructCodecsSchema
- StructDecoders
- StructEncoders
- TrackDecodeFn
- TupleCodecs
- TupleDecoders
- TupleEncoders
- U128
- U16
- U32
- U64
- U8
- Unit
- VariantAny
- VariantToFactoryArgs
- VecU8
Variables
Functions
- buildDecodeTraceStepsFmt
- countPositiveBigIntEffectiveBytes
- createArrayCodec
- createArrayDecoder
- createArrayEncoder
- createArrayU8Codec
- createBigIntDecoder
- createBigIntEncoder
- createEnumCodec
- createEnumDecoder
- createEnumEncoder
- createIntDecoder
- createIntEncoder
- createMapCodec
- createMapDecoder
- createMapEncoder
- createOptionCodec
- createOptionDecoder
- createOptionEncoder
- createResultCodec
- createResultDecoder
- createResultEncoder
- createSetCodec
- createSetDecoder
- createSetEncoder
- createStructCodec
- createStructDecoder
- createStructEncoder
- createTupleCodec
- createTupleDecoder
- createTupleEncoder
- createUint8ArrayDecoder
- createUint8ArrayEncoder
- createVecCodec
- 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
- dynCodec
- 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
- formatWalkerStep
- getCurrentTracker
- isTrackValueInspectable
- setCurrentTracker
- trackDecode
- trackRefineDecodeLoc
- trackableCodec
- tryInspectValue
- 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
Bool
Ƭ Bool: boolean
Defined in
packages/definition-runtime/src/codecs.ts:72
packages/definition-runtime/src/codecs.ts:73
CodecAny
Ƭ CodecAny: Codec
<any
, any
>
Defined in
packages/definition-runtime/src/core.ts:15
CodecArray
Ƭ CodecArray<T
>: Codec
<T
> & DefineOpaque
<T
[number
][], T
>
Type parameters
Name | Type |
---|---|
T | extends any [] |
Defined in
packages/definition-runtime/src/create.ts:49
CodecEnum
Ƭ CodecEnum<E
>: Codec
<E
> & EnumBoxToFactory
<E
>
Type parameters
Name | Type |
---|---|
E | extends EnumBox <any > |
Defined in
packages/definition-runtime/src/create.ts:136
CodecMap
Ƭ CodecMap<T
>: Codec
<T
> & DefineOpaque
<T
extends Map
<infer K, infer V> ? Map
<K
, V
> : never
, T
>
Type parameters
Name | Type |
---|---|
T | extends Map <any , any > |
Defined in
packages/definition-runtime/src/create.ts:220
CodecSet
Ƭ CodecSet<T
>: Codec
<T
> & DefineOpaque
<T
extends Set
<infer U> ? Set
<U
> : never
, T
>
Type parameters
Name | Type |
---|---|
T | extends Set <any > |
Defined in
packages/definition-runtime/src/create.ts:243
CodecStruct
Ƭ CodecStruct<T
>: Codec
<T
> & DefineOpaque
<FilterStringKeys
<T
>, T
>
Type parameters
Name |
---|
T |
Defined in
packages/definition-runtime/src/create.ts:199
CodecValueDecoded
Ƭ CodecValueDecoded<T
>: T
extends Codec
<any
, infer D> ? D
: never
Type parameters
Name | Type |
---|---|
T | extends Codec <any > |
Defined in
packages/definition-runtime/src/core.ts:62
CodecValueEncodable
Ƭ CodecValueEncodable<T
>: T
extends Codec
<infer E, any
> ? E
: never
Type parameters
Name | Type |
---|---|
T | extends Codec <any > |
Defined in
packages/definition-runtime/src/core.ts:60
Compact
Ƭ Compact: bigint
Defined in
packages/definition-runtime/src/codecs.ts:81
packages/definition-runtime/src/codecs.ts:82
Decode
Ƭ Decode<T
>: (walker
: Walker
) => T
Type parameters
Name |
---|
T |
Type declaration
▸ (walker
): T
Parameters
Name | Type |
---|---|
walker | Walker |
Returns
T
Defined in
DefineOpaque
Ƭ DefineOpaque<T
, U
>: (actual
: T
) => U
Type parameters
Name |
---|
T |
U |
Type declaration
▸ (actual
): U
U
should be the opaque version of T
Parameters
Name | Type |
---|---|
actual | T |
Returns
U
Defined in
packages/definition-runtime/src/create.ts:37
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
EnumBoxToFactory
Ƭ EnumBoxToFactory<E
>: E
extends EnumBox
<infer V> ? (...args
: VariantToFactoryArgs
<V
>) => E
: never
Type parameters
Name | Type |
---|---|
E | extends EnumBox <any > |
Defined in
packages/definition-runtime/src/create.ts:132
EnumCodecSchema
Ƭ EnumCodecSchema: [discriminant: number, tag: string, codec?: Codec<any>][]
Defined in
packages/definition-runtime/src/create.ts:119
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
FilterStringKeys
Ƭ FilterStringKeys<T
>: { [K in keyof T & string]: T[K] }
Type parameters
Name |
---|
T |
Defined in
packages/definition-runtime/src/create.ts:195
I128
Ƭ I128: bigint
Defined in
packages/definition-runtime/src/codecs.ts:64
packages/definition-runtime/src/codecs.ts:65
I16
Ƭ I16: number
Defined in
packages/definition-runtime/src/codecs.ts:46
packages/definition-runtime/src/codecs.ts:47
I32
Ƭ I32: number
Defined in
packages/definition-runtime/src/codecs.ts:52
packages/definition-runtime/src/codecs.ts:53
I64
Ƭ I64: bigint
Defined in
packages/definition-runtime/src/codecs.ts:58
packages/definition-runtime/src/codecs.ts:59
I8
Ƭ I8: number
Defined in
packages/definition-runtime/src/codecs.ts:40
packages/definition-runtime/src/codecs.ts:41
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
RefineDecodeLocFn
Ƭ RefineDecodeLocFn: <T>(loc
: string
, headlessDecode
: () => T
) => T
Type declaration
▸ <T
>(loc
, headlessDecode
): T
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
loc | string |
headlessDecode | () => T |
Returns
T
Defined in
packages/definition-runtime/src/tracking/types.ts:17
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
Str
Ƭ Str: string
Defined in
packages/definition-runtime/src/codecs.ts:69
packages/definition-runtime/src/codecs.ts:70
StructCodecsSchema
Ƭ StructCodecsSchema<T
>: { [K in keyof T]: [K, Codec<T[K]>] }[keyof T
][]
Type parameters
Name |
---|
T |
Defined in
packages/definition-runtime/src/create.ts:191
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
TrackDecodeFn
Ƭ TrackDecodeFn: <T>(loc
: string
, walker
: Walker
, decode
: Decode
<T
>) => T
Type declaration
▸ <T
>(loc
, walker
, decode
): T
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
loc | string |
walker | Walker |
decode | Decode <T > |
Returns
T
Defined in
packages/definition-runtime/src/tracking/types.ts:15
TupleCodecs
Ƭ TupleCodecs<T
>: T
extends [infer Head, ...(infer Tail)] ? [Codec
<Head
>, ...TupleCodecs<Tail>] : []
Type parameters
Name | Type |
---|---|
T | extends any [] |
Defined in
packages/definition-runtime/src/create.ts:86
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
U128
Ƭ U128: bigint
Defined in
packages/definition-runtime/src/codecs.ts:61
packages/definition-runtime/src/codecs.ts:62
U16
Ƭ U16: number
Defined in
packages/definition-runtime/src/codecs.ts:43
packages/definition-runtime/src/codecs.ts:44
U32
Ƭ U32: number
Defined in
packages/definition-runtime/src/codecs.ts:49
packages/definition-runtime/src/codecs.ts:50
U64
Ƭ U64: bigint
Defined in
packages/definition-runtime/src/codecs.ts:55
packages/definition-runtime/src/codecs.ts:56
U8
Ƭ U8: number
Defined in
packages/definition-runtime/src/codecs.ts:37
packages/definition-runtime/src/codecs.ts:38
Unit
Ƭ Unit: null
Defined in
packages/definition-runtime/src/codecs.ts:75
packages/definition-runtime/src/codecs.ts:76
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
VecU8
Ƭ VecU8: Uint8Array
Defined in
packages/definition-runtime/src/codecs.ts:78
packages/definition-runtime/src/codecs.ts:79
Variables
Bool
• Bool: Codec
<boolean
, boolean
>
Defined in
packages/definition-runtime/src/codecs.ts:72
packages/definition-runtime/src/codecs.ts:73
Compact
• Compact: Codec
<bigint
, bigint
>
Defined in
packages/definition-runtime/src/codecs.ts:81
packages/definition-runtime/src/codecs.ts:82
I128
• I128: Codec
<bigint
, bigint
>
Defined in
packages/definition-runtime/src/codecs.ts:64
packages/definition-runtime/src/codecs.ts:65
I16
• I16: Codec
<number
, number
>
Defined in
packages/definition-runtime/src/codecs.ts:46
packages/definition-runtime/src/codecs.ts:47
I32
• I32: Codec
<number
, number
>
Defined in
packages/definition-runtime/src/codecs.ts:52
packages/definition-runtime/src/codecs.ts:53
I64
• I64: Codec
<bigint
, bigint
>
Defined in
packages/definition-runtime/src/codecs.ts:58
packages/definition-runtime/src/codecs.ts:59
I8
• I8: Codec
<number
, number
>
Defined in
packages/definition-runtime/src/codecs.ts:40
packages/definition-runtime/src/codecs.ts:41
Str
• Str: Codec
<string
, string
>
Defined in
packages/definition-runtime/src/codecs.ts:69
packages/definition-runtime/src/codecs.ts:70
TrackValueInspect
• Const
TrackValueInspect: typeof TrackValueInspect
This symbol could be used by tracker to inspect value
Defined in
packages/definition-runtime/src/tracking/types.ts:6
U128
• U128: Codec
<bigint
, bigint
>
Defined in
packages/definition-runtime/src/codecs.ts:61
packages/definition-runtime/src/codecs.ts:62
U16
• U16: Codec
<number
, number
>
Defined in
packages/definition-runtime/src/codecs.ts:43
packages/definition-runtime/src/codecs.ts:44
U32
• U32: Codec
<number
, number
>
Defined in
packages/definition-runtime/src/codecs.ts:49
packages/definition-runtime/src/codecs.ts:50
U64
• U64: Codec
<bigint
, bigint
>
Defined in
packages/definition-runtime/src/codecs.ts:55
packages/definition-runtime/src/codecs.ts:56
U8
• U8: Codec
<number
, number
>
Defined in
packages/definition-runtime/src/codecs.ts:37
packages/definition-runtime/src/codecs.ts:38
Unit
• Unit: Codec
<null
, null
>
Defined in
packages/definition-runtime/src/codecs.ts:75
packages/definition-runtime/src/codecs.ts:76
VecU8
• VecU8: Codec
<Uint8Array
, Uint8Array
>
Defined in
packages/definition-runtime/src/codecs.ts:78
packages/definition-runtime/src/codecs.ts:79
Functions
buildDecodeTraceStepsFmt
▸ buildDecodeTraceStepsFmt(trace
, walker
): Fmt
Remarks
This function shouldn't be in the DecodeTrace
class itself due to provide a tree-shaking possibility. This is not the main part of this class, but the side tool, used for pretty-print in the console.
Parameters
Name | Type |
---|---|
trace | DecodeTrace |
walker | Walker |
Returns
Fmt
Defined in
packages/definition-runtime/src/tracking/decode-trace.ts:160
countPositiveBigIntEffectiveBytes
▸ countPositiveBigIntEffectiveBytes(positiveNum
): number
Parameters
Name | Type |
---|---|
positiveNum | bigint |
Returns
number
Defined in
packages/core/src/codecs/int.ts:172
createArrayCodec
▸ createArrayCodec<T
>(name
, itemCodec
, len
): CodecArray
<T
>
Type parameters
Name | Type |
---|---|
T | extends any [] |
Parameters
Name | Type |
---|---|
name | string |
itemCodec | Codec <T extends I [] ? I : never , T extends I [] ? I : never > |
len | number |
Returns
CodecArray
<T
>
Defined in
packages/definition-runtime/src/create.ts:51
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
createArrayU8Codec
▸ createArrayU8Codec(name
, len
): Codec
<Uint8Array
>
Parameters
Name | Type |
---|---|
name | string |
len | number |
Returns
Codec
<Uint8Array
>
Defined in
packages/definition-runtime/src/create.ts:67
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
createEnumCodec
▸ createEnumCodec<E
>(name
, schema
): CodecEnum
<E
>
Type parameters
Name | Type |
---|---|
E | extends EnumBox <any , E > |
Parameters
Name | Type |
---|---|
name | string |
schema | EnumCodecSchema |
Returns
CodecEnum
<E
>
Defined in
packages/definition-runtime/src/create.ts:140
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
createMapCodec
▸ createMapCodec<T
>(name
, keyCodec
, valueCodec
): CodecMap
<T
>
Type parameters
Name | Type |
---|---|
T | extends Map <any , any , T > |
Parameters
Name | Type |
---|---|
name | string |
keyCodec | Codec <T extends Map <K , any > ? K : never , T extends Map <K , any > ? K : never > |
valueCodec | Codec <T extends Map <any , V > ? V : never , T extends Map <any , V > ? V : never > |
Returns
CodecMap
<T
>
Defined in
packages/definition-runtime/src/create.ts:223
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
createOptionCodec
▸ createOptionCodec<T
>(name
, someCodec
): CodecEnum
<EnumBox
<RustOption
<T
>>>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
name | string |
someCodec | Codec <T , T > |
Returns
CodecEnum
<EnumBox
<RustOption
<T
>>>
Defined in
packages/definition-runtime/src/create.ts:171
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
createResultCodec
▸ createResultCodec<Ok
, Err
>(name
, okCodec
, errCodec
): CodecEnum
<EnumBox
<RustResult
<Ok
, Err
>>>
Type parameters
Name |
---|
Ok |
Err |
Parameters
Name | Type |
---|---|
name | string |
okCodec | Codec <Ok , Ok > |
errCodec | Codec <Err , Err > |
Returns
CodecEnum
<EnumBox
<RustResult
<Ok
, Err
>>>
Defined in
packages/definition-runtime/src/create.ts:178
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
createSetCodec
▸ createSetCodec<T
>(name
, itemCodec
): CodecSet
<T
>
Type parameters
Name | Type |
---|---|
T | extends Set <any , T > |
Parameters
Name | Type |
---|---|
name | string |
itemCodec | Codec <T extends Set <V > ? V : never , T extends Set <V > ? V : never > |
Returns
CodecSet
<T
>
Defined in
packages/definition-runtime/src/create.ts:245
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
createStructCodec
▸ createStructCodec<T
>(name
, orderedCodecs
): CodecStruct
<T
>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
name | string |
orderedCodecs | StructCodecsSchema <FilterStringKeys <T >> |
Returns
CodecStruct
<T
>
Defined in
packages/definition-runtime/src/create.ts:201
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
createTupleCodec
▸ createTupleCodec<T
, U
>(name
, codecs
): Codec
<U
> & DefineOpaque
<T
, U
>
Type parameters
Name | Type |
---|---|
T | extends any [] |
U | U |
Parameters
Name | Type |
---|---|
name | string |
codecs | TupleCodecs <T > |
Returns
Codec
<U
> & DefineOpaque
<T
, U
>
Defined in
packages/definition-runtime/src/create.ts:90
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
createVecCodec
▸ createVecCodec<T
>(name
, itemCodec
): CodecArray
<T
>
Type parameters
Name | Type |
---|---|
T | extends any [] |
Parameters
Name | Type |
---|---|
name | string |
itemCodec | Codec <T extends V [] ? V : never , T extends V [] ? V : never > |
Returns
CodecArray
<T
>
Defined in
packages/definition-runtime/src/create.ts:71
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
dynCodec
▸ dynCodec<C
>(getter
): Codec
<CodecValueEncodable
<C
>, CodecValueDecoded
<C
>>
Type parameters
Name | Type |
---|---|
C | extends Codec <any , any , C > |
Parameters
Name | Type |
---|---|
getter | () => C |
Returns
Codec
<CodecValueEncodable
<C
>, CodecValueDecoded
<C
>>
Defined in
packages/definition-runtime/src/core.ts:110
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
formatWalkerStep
▸ formatWalkerStep(params
): string
Parameters
Name | Type |
---|---|
params | FormatWalkerStepParams |
Returns
string
Defined in
packages/definition-runtime/src/tracking/util.ts:36
getCurrentTracker
▸ getCurrentTracker(): null
| CodecTracker
Caution: uses global state
Returns
null
| CodecTracker
Defined in
packages/definition-runtime/src/tracking/current.ts:9
isTrackValueInspectable
▸ isTrackValueInspectable(value
): value is TrackValueInspectable
Parameters
Name | Type |
---|---|
value | unknown |
Returns
value is TrackValueInspectable
Defined in
packages/definition-runtime/src/tracking/util.ts:44
setCurrentTracker
▸ setCurrentTracker(tracker
): void
Caution: uses global state
Parameters
Name | Type |
---|---|
tracker | null | CodecTracker |
Returns
void
Defined in
packages/definition-runtime/src/tracking/current.ts:16
trackDecode
▸ trackDecode<T
>(loc
, walker
, decode
): T
Caution: uses global state
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
loc | string |
walker | Walker |
decode | Decode <T > |
Returns
T
Defined in
packages/definition-runtime/src/tracking/types.ts:15
trackRefineDecodeLoc
▸ trackRefineDecodeLoc<T
>(loc
, headlessDecode
): T
Caution: uses global state
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
loc | string |
headlessDecode | () => T |
Returns
T
Defined in
packages/definition-runtime/src/tracking/types.ts:17
trackableCodec
▸ trackableCodec<E
, D
>(name
, encode
, decode
): Codec
<E
, D
>
Type parameters
Name | Type |
---|---|
E | E |
D | E |
Parameters
Name | Type |
---|---|
name | string |
encode | Encode <E > |
decode | Decode <D > |
Returns
Codec
<E
, D
>
Defined in
packages/definition-runtime/src/core.ts:48
tryInspectValue
▸ tryInspectValue(value
): any
Parameters
Name | Type |
---|---|
value | any |
Returns
any
Defined in
packages/definition-runtime/src/tracking/util.ts:48
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
>