assertIsFixedSize
Call Signature
Asserts that the given codec, encoder, or decoder is fixed-size.
If the object is not fixed-size (i.e., it lacks a fixedSize property),
this function throws a SolanaError with the code SOLANA_ERROR__CODECS__EXPECTED_FIXED_LENGTH.
Type Parameters
| Type Parameter | Description |
|---|---|
TFrom | The type of the value to encode. |
TSize extends number | The fixed size of the encoded value in bytes. |
Parameters
| Parameter | Type |
|---|---|
encoder | | FixedSizeEncoder<TFrom, TSize> | VariableSizeEncoder<TFrom> |
Returns
asserts encoder is FixedSizeEncoder<TFrom, TSize>
Throws
If the object is not fixed-size.
Examples
Asserting a fixed-size encoder.
Attempting to assert a variable-size encoder.
Remarks
This function is the assertion-based counterpart of isFixedSize. If you only need to check whether an object is fixed-size without throwing an error, use isFixedSize instead.
See
Call Signature
Asserts that the given codec, encoder, or decoder is fixed-size.
If the object is not fixed-size (i.e., it lacks a fixedSize property),
this function throws a SolanaError with the code SOLANA_ERROR__CODECS__EXPECTED_FIXED_LENGTH.
Type Parameters
| Type Parameter | Description |
|---|---|
TTo | The type of the decoded value. |
TSize extends number | The fixed size of the encoded value in bytes. |
Parameters
| Parameter | Type |
|---|---|
decoder | | FixedSizeDecoder<TTo, TSize> | VariableSizeDecoder<TTo> |
Returns
asserts decoder is FixedSizeDecoder<TTo, TSize>
Throws
If the object is not fixed-size.
Examples
Asserting a fixed-size encoder.
Attempting to assert a variable-size encoder.
Remarks
This function is the assertion-based counterpart of isFixedSize. If you only need to check whether an object is fixed-size without throwing an error, use isFixedSize instead.
See
Call Signature
Asserts that the given codec, encoder, or decoder is fixed-size.
If the object is not fixed-size (i.e., it lacks a fixedSize property),
this function throws a SolanaError with the code SOLANA_ERROR__CODECS__EXPECTED_FIXED_LENGTH.
Type Parameters
| Type Parameter | Description |
|---|---|
TFrom | The type of the value to encode. |
TTo | The type of the decoded value. |
TSize extends number | The fixed size of the encoded value in bytes. |
Parameters
| Parameter | Type |
|---|---|
codec | | FixedSizeCodec<TFrom, TTo, TSize> | VariableSizeCodec<TFrom, TTo> |
Returns
asserts codec is FixedSizeCodec<TFrom, TTo, TSize>
Throws
If the object is not fixed-size.
Examples
Asserting a fixed-size encoder.
Attempting to assert a variable-size encoder.
Remarks
This function is the assertion-based counterpart of isFixedSize. If you only need to check whether an object is fixed-size without throwing an error, use isFixedSize instead.
See
Call Signature
Asserts that the given codec, encoder, or decoder is fixed-size.
If the object is not fixed-size (i.e., it lacks a fixedSize property),
this function throws a SolanaError with the code SOLANA_ERROR__CODECS__EXPECTED_FIXED_LENGTH.
Type Parameters
| Type Parameter | Description |
|---|---|
TSize extends number | The fixed size of the encoded value in bytes. |
Parameters
| Parameter | Type |
|---|---|
codec | | { fixedSize: TSize; } | { maxSize?: number; } |
Returns
asserts codec is { fixedSize: TSize }
Throws
If the object is not fixed-size.
Examples
Asserting a fixed-size encoder.
Attempting to assert a variable-size encoder.
Remarks
This function is the assertion-based counterpart of isFixedSize. If you only need to check whether an object is fixed-size without throwing an error, use isFixedSize instead.