@wildboar/rose
Version:
Remote Operation Service Element PDUs in TypeScript
48 lines (47 loc) • 2.07 kB
JavaScript
import * as $ from '@wildboar/asn1/functional';
import { _decode_Bind, _encode_Bind, } from '../Remote-Operations-Generic-ROS-PDUs/Bind.ta.mjs';
import { _decode_Unbind, _encode_Unbind, } from '../Remote-Operations-Generic-ROS-PDUs/Unbind.ta.mjs';
import { _decode_ROS_SingleAS, _encode_ROS_SingleAS, } from '../Remote-Operations-Abstract-Syntaxes/ROS-SingleAS.ta.mjs';
let _cached_decoder_for_AllValues = null;
/**
* @summary Decodes an ASN.1 element into a(n) AllValues
* @function
* @param {_Element} el The element being decoded.
* @returns {AllValues} The decoded data structure.
*/
export function _decode_AllValues(el) {
if (!_cached_decoder_for_AllValues) {
_cached_decoder_for_AllValues = $._decode_inextensible_choice({
'CONTEXT 16': ['bind', _decode_Bind],
'CONTEXT 17': ['bind', _decode_Bind],
'CONTEXT 18': ['bind', _decode_Bind],
'CONTEXT 19': ['unbind', _decode_Unbind],
'CONTEXT 20': ['unbind', _decode_Unbind],
'CONTEXT 21': ['unbind', _decode_Unbind],
'CONTEXT 1': ['ros_singleAS', _decode_ROS_SingleAS],
'CONTEXT 2': ['ros_singleAS', _decode_ROS_SingleAS],
'CONTEXT 3': ['ros_singleAS', _decode_ROS_SingleAS],
'CONTEXT 4': ['ros_singleAS', _decode_ROS_SingleAS],
});
}
return _cached_decoder_for_AllValues(el);
}
let _cached_encoder_for_AllValues = null;
/**
* @summary Encodes a(n) AllValues 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 AllValues, encoded as an ASN.1 Element.
*/
export function _encode_AllValues(value, elGetter) {
if (!_cached_encoder_for_AllValues) {
_cached_encoder_for_AllValues = $._encode_choice({
bind: _encode_Bind,
unbind: _encode_Unbind,
ros_singleAS: _encode_ROS_SingleAS,
}, $.BER);
}
return _cached_encoder_for_AllValues(value, elGetter);
}
/* eslint-enable */