UNPKG

@wildboar/copp

Version:

Connection-oriented presentation protocol (COPP) data structures and business logic in TypeScript

50 lines (49 loc) 2.11 kB
/* eslint-disable */ import { ASN1TagClass as _TagClass, } from '@wildboar/asn1'; import * as $ from '@wildboar/asn1/functional'; import { _decode_AC_PPDU, _encode_AC_PPDU, } from '../ISO8823-PRESENTATION/AC-PPDU.ta.mjs'; import { _decode_ACA_PPDU, _encode_ACA_PPDU, } from '../ISO8823-PRESENTATION/ACA-PPDU.ta.mjs'; import { _decode_User_data, _encode_User_data, } from '../ISO8823-PRESENTATION/User-data.ta.mjs'; let _cached_decoder_for_Typed_data_type = null; /** * @summary Decodes an ASN.1 element into a(n) Typed_data_type * @function * @param {_Element} el The element being decoded. * @returns {Typed_data_type} The decoded data structure. */ export function _decode_Typed_data_type(el) { if (!_cached_decoder_for_Typed_data_type) { _cached_decoder_for_Typed_data_type = $._decode_inextensible_choice({ 'CONTEXT 0': [ 'acPPDU', $._decode_implicit(() => _decode_AC_PPDU), ], 'CONTEXT 1': [ 'acaPPDU', $._decode_implicit(() => _decode_ACA_PPDU), ], 'APPLICATION 0': ['ttdPPDU', _decode_User_data], 'APPLICATION 1': ['ttdPPDU', _decode_User_data], }); } return _cached_decoder_for_Typed_data_type(el); } let _cached_encoder_for_Typed_data_type = null; /** * @summary Encodes a(n) Typed_data_type into an ASN.1 Element. * @function * @param value The element being encoded. * @param elGetter A function that can be used to get new ASN.1 elements. * @returns {_Element} The Typed_data_type, encoded as an ASN.1 Element. */ export function _encode_Typed_data_type(value, elGetter) { if (!_cached_encoder_for_Typed_data_type) { _cached_encoder_for_Typed_data_type = $._encode_choice({ acPPDU: $._encode_implicit(_TagClass.context, 0, () => _encode_AC_PPDU, $.BER), acaPPDU: $._encode_implicit(_TagClass.context, 1, () => _encode_ACA_PPDU, $.BER), ttdPPDU: _encode_User_data, }, $.BER); } return _cached_encoder_for_Typed_data_type(value, elGetter); } /* eslint-enable */