getPatternMatchDecoder
Call Signature
Returns a decoder that selects which variant decoder to use based on pattern matching.
This decoder evaluates the byte array against a series of predicate functions in order, and uses the first matching decoder to decode the value.
Type Parameters
| Type Parameter | Description |
|---|---|
TTo | The type of the value to decode. |
TSize extends number | - |
Parameters
| Parameter | Type | Description |
|---|---|---|
patterns | [(value) => boolean, FixedSizeDecoder<TTo, TSize>][] | An array of [predicate, decoder] pairs. Predicates are tested in order and the first matching decoder is used to decode the byte array. |
Returns
FixedSizeDecoder<TTo, TSize>
A decoder that selects the appropriate variant based on the matched byte pattern.
Throws
Throws a SOLANA_ERROR__CODECS__INVALID_PATTERN_MATCH_BYTES error if the byte array does not match any of the specified patterns.
Example
Decoding values using pattern matching on bytes.
See
Call Signature
Returns a decoder that selects which variant decoder to use based on pattern matching.
This decoder evaluates the byte array against a series of predicate functions in order, and uses the first matching decoder to decode the value.
Type Parameters
| Type Parameter | Description |
|---|---|
TTo | The type of the value to decode. |
Parameters
| Parameter | Type | Description |
|---|---|---|
patterns | [(value) => boolean, FixedSizeDecoder<TTo>][] | An array of [predicate, decoder] pairs. Predicates are tested in order and the first matching decoder is used to decode the byte array. |
Returns
FixedSizeDecoder<TTo>
A decoder that selects the appropriate variant based on the matched byte pattern.
Throws
Throws a SOLANA_ERROR__CODECS__INVALID_PATTERN_MATCH_BYTES error if the byte array does not match any of the specified patterns.
Example
Decoding values using pattern matching on bytes.
See
Call Signature
Returns a decoder that selects which variant decoder to use based on pattern matching.
This decoder evaluates the byte array against a series of predicate functions in order, and uses the first matching decoder to decode the value.
Type Parameters
| Type Parameter | Description |
|---|---|
TTo | The type of the value to decode. |
Parameters
| Parameter | Type | Description |
|---|---|---|
patterns | [(value) => boolean, VariableSizeDecoder<TTo>][] | An array of [predicate, decoder] pairs. Predicates are tested in order and the first matching decoder is used to decode the byte array. |
Returns
VariableSizeDecoder<TTo>
A decoder that selects the appropriate variant based on the matched byte pattern.
Throws
Throws a SOLANA_ERROR__CODECS__INVALID_PATTERN_MATCH_BYTES error if the byte array does not match any of the specified patterns.
Example
Decoding values using pattern matching on bytes.
See
Call Signature
Returns a decoder that selects which variant decoder to use based on pattern matching.
This decoder evaluates the byte array against a series of predicate functions in order, and uses the first matching decoder to decode the value.
Type Parameters
| Type Parameter | Description |
|---|---|
TTo | The type of the value to decode. |
Parameters
| Parameter | Type | Description |
|---|---|---|
patterns | [(value) => boolean, Decoder<TTo>][] | An array of [predicate, decoder] pairs. Predicates are tested in order and the first matching decoder is used to decode the byte array. |
Returns
Decoder<TTo>
A decoder that selects the appropriate variant based on the matched byte pattern.
Throws
Throws a SOLANA_ERROR__CODECS__INVALID_PATTERN_MATCH_BYTES error if the byte array does not match any of the specified patterns.
Example
Decoding values using pattern matching on bytes.