Options
All
  • Public
  • Public/Protected
  • All
Menu

Represent a specific variant within a containing union.

NOTE The {@link Layout#span|span} of the variant may include the span of the {@link Union#discriminator|discriminator} used to identify it, but values read and written using the variant strictly conform to the content of {@link VariantLayout#layout|layout}.

NOTE User code should not invoke this constructor directly. Use the union {@link Union#addVariant|addVariant} helper method.

param union

initializer for {@link VariantLayout#union|union}.

param variant

initializer for {@link VariantLayout#variant|variant}.

param [layout]

initializer for {@link VariantLayout#layout|layout}. If absent the variant carries no data.

param [property]

initializer for {@link Layout#property|property}. Unlike many other layouts, variant layouts normally include a property name so they can be identified within their containing Union. The property identifier may be absent only if layout is is absent.

Hierarchy

Index

Constructors

constructor

Properties

Optional boundConstructor_

boundConstructor_?: any

layout

layout: null | Layout<LayoutObject>

property

property: string

span

span: number

union

union: Union

variant

variant: number

Methods

decode

encode

  • encode(src: LayoutObject, b: Uint8Array, offset?: number): number

fromArray

getSpan

  • getSpan(b: Uint8Array, offset?: number): number

makeDestinationObject

replicate

  • Replicate the layout using a new property.

    This function must be used to get a structurally-equivalent layout with a different name since all Layout instances are immutable.

    NOTE This is a shallow copy. All fields except {@link Layout#property|property} are strictly equal to the origin layout.

    Parameters

    • property: string

      the value for {@link Layout#property|property} in the replica.

    Returns VariantLayout

    • the copy with {@link Layout#property|property} set to property.

Generated using TypeDoc