UNPKG

@wildboar/acse

Version:
56 lines (55 loc) 2.48 kB
import * as $ from '@wildboar/asn1/functional'; import { _decode_AARQ_apdu, _encode_AARQ_apdu, } from '../ACSE-1/AARQ-apdu.ta.mjs'; import { _decode_AARE_apdu, _encode_AARE_apdu, } from '../ACSE-1/AARE-apdu.ta.mjs'; import { _decode_RLRQ_apdu, _encode_RLRQ_apdu, } from '../ACSE-1/RLRQ-apdu.ta.mjs'; import { _decode_RLRE_apdu, _encode_RLRE_apdu, } from '../ACSE-1/RLRE-apdu.ta.mjs'; import { _decode_ABRT_apdu, _encode_ABRT_apdu, } from '../ACSE-1/ABRT-apdu.ta.mjs'; import { _decode_A_DT_apdu, _encode_A_DT_apdu, } from '../ACSE-1/A-DT-apdu.ta.mjs'; import { _decode_ACRQ_apdu, _encode_ACRQ_apdu, } from '../ACSE-1/ACRQ-apdu.ta.mjs'; import { _decode_ACRP_apdu, _encode_ACRP_apdu, } from '../ACSE-1/ACRP-apdu.ta.mjs'; let _cached_decoder_for_ACSE_apdu = null; /** * @summary Decodes an ASN.1 element into a(n) ACSE_apdu * @function * @param {_Element} el The element being decoded. * @returns {ACSE_apdu} The decoded data structure. */ export function _decode_ACSE_apdu(el) { if (!_cached_decoder_for_ACSE_apdu) { _cached_decoder_for_ACSE_apdu = $._decode_extensible_choice({ 'APPLICATION 0': ['aarq', _decode_AARQ_apdu], 'APPLICATION 1': ['aare', _decode_AARE_apdu], 'APPLICATION 2': ['rlrq', _decode_RLRQ_apdu], 'APPLICATION 3': ['rlre', _decode_RLRE_apdu], 'APPLICATION 4': ['abrt', _decode_ABRT_apdu], 'APPLICATION 5': ['adt', _decode_A_DT_apdu], 'APPLICATION 6': ['acrq', _decode_ACRQ_apdu], 'APPLICATION 7': ['acrp', _decode_ACRP_apdu], }); } return _cached_decoder_for_ACSE_apdu(el); } let _cached_encoder_for_ACSE_apdu = null; /** * @summary Encodes a(n) ACSE_apdu 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 ACSE_apdu, encoded as an ASN.1 Element. */ export function _encode_ACSE_apdu(value, elGetter) { if (!_cached_encoder_for_ACSE_apdu) { _cached_encoder_for_ACSE_apdu = $._encode_choice({ aarq: _encode_AARQ_apdu, aare: _encode_AARE_apdu, rlrq: _encode_RLRQ_apdu, rlre: _encode_RLRE_apdu, abrt: _encode_ABRT_apdu, adt: _encode_A_DT_apdu, acrq: _encode_ACRQ_apdu, acrp: _encode_ACRP_apdu, }, $.BER); } return _cached_encoder_for_ACSE_apdu(value, elGetter); } /* eslint-enable */