ardunno-cli
Version:
nice-grpc API for the Arduino CLI
242 lines (241 loc) • 8.6 kB
JavaScript
;
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.181.2
// protoc v3.20.3
// source: cc/arduino/cli/commands/v1/port.proto
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Port_PropertiesEntry = exports.Port = void 0;
/* eslint-disable */
const minimal_1 = __importDefault(require("protobufjs/minimal"));
function createBasePort() {
return {
address: '',
label: '',
protocol: '',
protocolLabel: '',
properties: {},
hardwareId: '',
};
}
exports.Port = {
encode(message, writer = minimal_1.default.Writer.create()) {
if (message.address !== '') {
writer.uint32(10).string(message.address);
}
if (message.label !== '') {
writer.uint32(18).string(message.label);
}
if (message.protocol !== '') {
writer.uint32(26).string(message.protocol);
}
if (message.protocolLabel !== '') {
writer.uint32(34).string(message.protocolLabel);
}
Object.entries(message.properties).forEach(([key, value]) => {
exports.Port_PropertiesEntry.encode({ key: key, value }, writer.uint32(42).fork()).ldelim();
});
if (message.hardwareId !== '') {
writer.uint32(50).string(message.hardwareId);
}
return writer;
},
decode(input, length) {
const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePort();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.address = reader.string();
continue;
case 2:
if (tag !== 18) {
break;
}
message.label = reader.string();
continue;
case 3:
if (tag !== 26) {
break;
}
message.protocol = reader.string();
continue;
case 4:
if (tag !== 34) {
break;
}
message.protocolLabel = reader.string();
continue;
case 5:
if (tag !== 42) {
break;
}
const entry5 = exports.Port_PropertiesEntry.decode(reader, reader.uint32());
if (entry5.value !== undefined) {
message.properties[entry5.key] = entry5.value;
}
continue;
case 6:
if (tag !== 50) {
break;
}
message.hardwareId = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
address: isSet(object.address) ? globalThis.String(object.address) : '',
label: isSet(object.label) ? globalThis.String(object.label) : '',
protocol: isSet(object.protocol)
? globalThis.String(object.protocol)
: '',
protocolLabel: isSet(object.protocolLabel)
? globalThis.String(object.protocolLabel)
: '',
properties: isObject(object.properties)
? Object.entries(object.properties).reduce((acc, [key, value]) => {
acc[key] = String(value);
return acc;
}, {})
: {},
hardwareId: isSet(object.hardwareId)
? globalThis.String(object.hardwareId)
: '',
};
},
toJSON(message) {
const obj = {};
if (message.address !== '') {
obj.address = message.address;
}
if (message.label !== '') {
obj.label = message.label;
}
if (message.protocol !== '') {
obj.protocol = message.protocol;
}
if (message.protocolLabel !== '') {
obj.protocolLabel = message.protocolLabel;
}
if (message.properties) {
const entries = Object.entries(message.properties);
if (entries.length > 0) {
obj.properties = {};
entries.forEach(([k, v]) => {
obj.properties[k] = v;
});
}
}
if (message.hardwareId !== '') {
obj.hardwareId = message.hardwareId;
}
return obj;
},
create(base) {
return exports.Port.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b, _c, _d, _e, _f;
const message = createBasePort();
message.address = (_a = object.address) !== null && _a !== void 0 ? _a : '';
message.label = (_b = object.label) !== null && _b !== void 0 ? _b : '';
message.protocol = (_c = object.protocol) !== null && _c !== void 0 ? _c : '';
message.protocolLabel = (_d = object.protocolLabel) !== null && _d !== void 0 ? _d : '';
message.properties = Object.entries((_e = object.properties) !== null && _e !== void 0 ? _e : {}).reduce((acc, [key, value]) => {
if (value !== undefined) {
acc[key] = globalThis.String(value);
}
return acc;
}, {});
message.hardwareId = (_f = object.hardwareId) !== null && _f !== void 0 ? _f : '';
return message;
},
};
function createBasePort_PropertiesEntry() {
return { key: '', value: '' };
}
exports.Port_PropertiesEntry = {
encode(message, writer = minimal_1.default.Writer.create()) {
if (message.key !== '') {
writer.uint32(10).string(message.key);
}
if (message.value !== '') {
writer.uint32(18).string(message.value);
}
return writer;
},
decode(input, length) {
const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePort_PropertiesEntry();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.key = reader.string();
continue;
case 2:
if (tag !== 18) {
break;
}
message.value = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
key: isSet(object.key) ? globalThis.String(object.key) : '',
value: isSet(object.value) ? globalThis.String(object.value) : '',
};
},
toJSON(message) {
const obj = {};
if (message.key !== '') {
obj.key = message.key;
}
if (message.value !== '') {
obj.value = message.value;
}
return obj;
},
create(base) {
return exports.Port_PropertiesEntry.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b;
const message = createBasePort_PropertiesEntry();
message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
message.value = (_b = object.value) !== null && _b !== void 0 ? _b : '';
return message;
},
};
function isObject(value) {
return typeof value === 'object' && value !== null;
}
function isSet(value) {
return value !== null && value !== undefined;
}