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