UNPKG

@wildboar/rose

Version:
161 lines (160 loc) 5.32 kB
import * as $ from '@wildboar/asn1/functional'; import { _decode_Code, _encode_Code, } from '../Remote-Operations-Information-Objects/Code.ta.mjs'; import { _decode_InvokeId, _encode_InvokeId, } from '../Remote-Operations-Generic-ROS-PDUs/InvokeId.ta.mjs'; /** * @summary ReturnError * @description * * ### ASN.1 Definition: * * ```asn1 * ReturnError{ERROR:Errors} ::= SEQUENCE { * invokeId * InvokeId * (CONSTRAINED BY {-- must be that for an outstanding operation -- } ! * RejectProblem:returnError-unrecognizedInvocation) * (CONSTRAINED BY {-- which returns an error -- } ! * RejectProblem:returnError-errorResponseUnexpected), * errcode * ERROR.&errorCode({Errors} !RejectProblem:returnError-unrecognizedError) * (CONSTRAINED BY {-- must be in the &Errors field of the associated operation -- * } !RejectProblem:returnError-unexpectedError), * parameter * ERROR.&ParameterType * ({Errors}{@errcode} !RejectProblem:returnError-mistypedParameter) * OPTIONAL * } * (CONSTRAINED BY { -- must conform to the above definition --} ! * RejectProblem:general-mistypedPDU) * ``` * */ export class ReturnError { invokeId; errcode; parameter; constructor( /** * @summary `invokeId`. * @public * @readonly */ invokeId, /** * @summary `errcode`. * @public * @readonly */ errcode, /** * @summary `parameter`. * @public * @readonly */ parameter) { this.invokeId = invokeId; this.errcode = errcode; this.parameter = parameter; } /** * @summary Restructures an object into a ReturnError * @description * * This takes an `object` and converts it to a `ReturnError`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `ReturnError`. * @returns {ReturnError} */ static _from_object(_o) { return new ReturnError(_o.invokeId, _o.errcode, _o.parameter); } } /** * @summary The Leading Root Component Types of ReturnError * @description * * This is an array of `ComponentSpec`s that define how to decode the leading root component type list of a SET or SEQUENCE. * * @constant */ export const _root_component_type_list_1_spec_for_ReturnError = [ new $.ComponentSpec('invokeId', false, $.hasAnyTag), new $.ComponentSpec('errcode', false, $.hasAnyTag), new $.ComponentSpec('parameter', true, $.hasAnyTag), ]; /** * @summary The Trailing Root Component Types of ReturnError * @description * * This is an array of `ComponentSpec`s that define how to decode the trailing root component type list of a SET or SEQUENCE. * * @constant */ export const _root_component_type_list_2_spec_for_ReturnError = []; /** * @summary The Extension Addition Component Types of ReturnError * @description * * This is an array of `ComponentSpec`s that define how to decode the extension addition component type list of a SET or SEQUENCE. * * @constant */ export const _extension_additions_list_spec_for_ReturnError = []; let _cached_decoder_for_ReturnError = null; /** * @summary Decodes an ASN.1 element into a(n) ReturnError * @function * @param {_Element} el The element being decoded. * @returns {ReturnError} The decoded data structure. */ export function _decode_ReturnError(el) { if (!_cached_decoder_for_ReturnError) { _cached_decoder_for_ReturnError = function (el) { let invokeId; let errcode; let parameter; const callbacks = { invokeId: (_el) => { invokeId = _decode_InvokeId(_el); }, errcode: (_el) => { errcode = _decode_Code(_el); }, parameter: (_el) => { parameter = $._decodeAny(_el); }, }; $._parse_sequence(el, callbacks, _root_component_type_list_1_spec_for_ReturnError, _extension_additions_list_spec_for_ReturnError, _root_component_type_list_2_spec_for_ReturnError, undefined); return new ReturnError(invokeId, errcode, parameter); }; } return _cached_decoder_for_ReturnError(el); } let _cached_encoder_for_ReturnError = null; /** * @summary Encodes a(n) ReturnError 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 ReturnError, encoded as an ASN.1 Element. */ export function _encode_ReturnError(value, elGetter) { if (!_cached_encoder_for_ReturnError) { _cached_encoder_for_ReturnError = function (value) { return $._encodeSequence([] .concat([ /* REQUIRED */ _encode_InvokeId(value.invokeId, $.BER), /* REQUIRED */ _encode_Code(value.errcode, $.BER), /* IF_ABSENT */ value.parameter === undefined ? undefined : $._encodeAny(value.parameter, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_ReturnError(value, elGetter); } /* eslint-enable */