UNPKG

@wildboar/copp

Version:

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

46 lines (45 loc) 1.94 kB
/* eslint-disable */ import { ASN1TagClass as _TagClass, } from '@wildboar/asn1'; import * as $ from '@wildboar/asn1/functional'; import { _decode_Simply_encoded_data, _encode_Simply_encoded_data, } from '../ISO8823-PRESENTATION/Simply-encoded-data.ta.mjs'; import { _decode_Fully_encoded_data, _encode_Fully_encoded_data, } from '../ISO8823-PRESENTATION/Fully-encoded-data.ta.mjs'; let _cached_decoder_for_User_data = null; /** * @summary Decodes an ASN.1 element into a(n) User_data * @function * @param {_Element} el The element being decoded. * @returns {User_data} The decoded data structure. */ export function _decode_User_data(el) { if (!_cached_decoder_for_User_data) { _cached_decoder_for_User_data = $._decode_extensible_choice({ 'APPLICATION 0': [ 'simply_encoded_data', $._decode_implicit(() => _decode_Simply_encoded_data), ], 'APPLICATION 1': [ 'fully_encoded_data', $._decode_implicit(() => _decode_Fully_encoded_data), ], }); } return _cached_decoder_for_User_data(el); } let _cached_encoder_for_User_data = null; /** * @summary Encodes a(n) User_data 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 User_data, encoded as an ASN.1 Element. */ export function _encode_User_data(value, elGetter) { if (!_cached_encoder_for_User_data) { _cached_encoder_for_User_data = $._encode_choice({ simply_encoded_data: $._encode_implicit(_TagClass.application, 0, () => _encode_Simply_encoded_data, $.BER), fully_encoded_data: $._encode_implicit(_TagClass.application, 1, () => _encode_Fully_encoded_data, $.BER), }, $.BER); } return _cached_encoder_for_User_data(value, elGetter); } /* eslint-enable */