• Preparing search index...
  • The search index is not available
Solana JavaScript SDK
  • Solana JavaScript SDK
  • @solana/web3.js
  • getUnionCodec

Function getUnionCodec

  • getUnionCodec<const TVariants extends readonly Codec<any>[]>(
        variants: TVariants,
        getIndexFromValue: (value: GetEncoderTypeFromVariants<TVariants>) => number,
        getIndexFromBytes: (bytes: ReadonlyUint8Array, offset: number) => number,
    ): Codec<
        GetEncoderTypeFromVariants<TVariants>,
        GetDecoderTypeFromVariants<TVariants> & GetEncoderTypeFromVariants<
            TVariants,
        >,
    >
  • Creates a union codec from the provided array of codec.

    Type Parameters

    • const TVariants extends readonly Codec<any>[]

    Parameters

    • variants: TVariants

      The variant codecs of the union.

    • getIndexFromValue: (value: GetEncoderTypeFromVariants<TVariants>) => number

      A function that returns the index of the variant from the provided value.

    • getIndexFromBytes: (bytes: ReadonlyUint8Array, offset: number) => number

      A function that returns the index of the variant from the byte array.

    Returns Codec<
        GetEncoderTypeFromVariants<TVariants>,
        GetDecoderTypeFromVariants<TVariants> & GetEncoderTypeFromVariants<
            TVariants,
        >,
    >

    • Defined in packages/codecs-data-structures/dist/types/union.d.ts:30

Settings

Member Visibility
Solana JavaScript SDK
  • Loading...

Generated using TypeDoc