"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deserializeWrappedReq = exports.serializeWrappedReq = exports.cWrappedReqVersion = void 0;
const TypeIdentifierEnum_1 = require("./enum/TypeIdentifierEnum");
exports.cWrappedReqVersion = 1;
function serializeWrappedReq(stream, obj, root = false) {
    if (root) {
        stream.writeUInt16(TypeIdentifierEnum_1.TypeIdentifierEnum.cWrappedReq);
    }
    stream.writeUInt8(exports.cWrappedReqVersion);
    stream.writeBuffer(obj.payload);
}
exports.serializeWrappedReq = serializeWrappedReq;
function deserializeWrappedReq(stream) {
    const version = stream.readUInt8();
    if (version > exports.cWrappedReqVersion) {
        throw new Error('WrappedReq version mismatch');
    }
    const payload = stream.readBuffer();
    const obj = {
        payload,
    };
    return obj;
}
exports.deserializeWrappedReq = deserializeWrappedReq;
//# sourceMappingURL=WrappedReq.js.map