@wildboar/copp
Version:
Connection-oriented presentation protocol (COPP) data structures and business logic in TypeScript
44 lines (43 loc) • 1.8 kB
JavaScript
import * as $ from '@wildboar/asn1/functional';
import { _decode_CPR_PPDU_x400_mode_parameters, _encode_CPR_PPDU_x400_mode_parameters, } from '../ISO8823-PRESENTATION/CPR-PPDU-x400-mode-parameters.ta.mjs';
import { _decode_CPR_PPDU_normal_mode_parameters, _encode_CPR_PPDU_normal_mode_parameters, } from '../ISO8823-PRESENTATION/CPR-PPDU-normal-mode-parameters.ta.mjs';
let _cached_decoder_for_CPR_PPDU = null;
/**
* @summary Decodes an ASN.1 element into a(n) CPR_PPDU
* @function
* @param {_Element} el The element being decoded.
* @returns {CPR_PPDU} The decoded data structure.
*/
export function _decode_CPR_PPDU(el) {
if (!_cached_decoder_for_CPR_PPDU) {
_cached_decoder_for_CPR_PPDU = $._decode_inextensible_choice({
'UNIVERSAL 17': [
'x400_mode_parameters',
_decode_CPR_PPDU_x400_mode_parameters,
],
'UNIVERSAL 16': [
'normal_mode_parameters',
_decode_CPR_PPDU_normal_mode_parameters,
],
});
}
return _cached_decoder_for_CPR_PPDU(el);
}
let _cached_encoder_for_CPR_PPDU = null;
/**
* @summary Encodes a(n) CPR_PPDU 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 CPR_PPDU, encoded as an ASN.1 Element.
*/
export function _encode_CPR_PPDU(value, elGetter) {
if (!_cached_encoder_for_CPR_PPDU) {
_cached_encoder_for_CPR_PPDU = $._encode_choice({
x400_mode_parameters: _encode_CPR_PPDU_x400_mode_parameters,
normal_mode_parameters: _encode_CPR_PPDU_normal_mode_parameters,
}, $.BER);
}
return _cached_encoder_for_CPR_PPDU(value, elGetter);
}
/* eslint-enable */