43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
// automatically generated by the FlatBuffers compiler, do not modify
|
|
|
|
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
|
|
|
import { DecodeUnitBuffer } from '../video-update/decode-unit-buffer.js';
|
|
import { DecodeUnitStart } from '../video-update/decode-unit-start.js';
|
|
import { Setup } from '../video-update/setup.js';
|
|
|
|
|
|
export enum Update {
|
|
NONE = 0,
|
|
Setup = 1,
|
|
DecodeUnitStart = 2,
|
|
DecodeUnitBuffer = 3
|
|
}
|
|
|
|
export function unionToUpdate(
|
|
type: Update,
|
|
accessor: (obj:DecodeUnitBuffer|DecodeUnitStart|Setup) => DecodeUnitBuffer|DecodeUnitStart|Setup|null
|
|
): DecodeUnitBuffer|DecodeUnitStart|Setup|null {
|
|
switch(Update[type]) {
|
|
case 'NONE': return null;
|
|
case 'Setup': return accessor(new Setup())! as Setup;
|
|
case 'DecodeUnitStart': return accessor(new DecodeUnitStart())! as DecodeUnitStart;
|
|
case 'DecodeUnitBuffer': return accessor(new DecodeUnitBuffer())! as DecodeUnitBuffer;
|
|
default: return null;
|
|
}
|
|
}
|
|
|
|
export function unionListToUpdate(
|
|
type: Update,
|
|
accessor: (index: number, obj:DecodeUnitBuffer|DecodeUnitStart|Setup) => DecodeUnitBuffer|DecodeUnitStart|Setup|null,
|
|
index: number
|
|
): DecodeUnitBuffer|DecodeUnitStart|Setup|null {
|
|
switch(Update[type]) {
|
|
case 'NONE': return null;
|
|
case 'Setup': return accessor(index, new Setup())! as Setup;
|
|
case 'DecodeUnitStart': return accessor(index, new DecodeUnitStart())! as DecodeUnitStart;
|
|
case 'DecodeUnitBuffer': return accessor(index, new DecodeUnitBuffer())! as DecodeUnitBuffer;
|
|
default: return null;
|
|
}
|
|
}
|