Files
Vermix-Web/src/generated/proto/control_communication.ts
T
2025-10-06 18:11:03 +02:00

378 lines
11 KiB
TypeScript

// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v2.7.7
// protoc v3.21.12
// source: proto/control_communication.proto
/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
export const protobufPackage = "control_communication";
export interface RfidId {
value: number;
}
export interface SyncResponse {
currentTime: number;
pendingChanges: boolean;
}
export interface SyncRequest {
lastSync?: number | undefined;
accessLogs: { [key: number]: number };
}
export interface SyncRequest_AccessLogsEntry {
key: number;
value: number;
}
function createBaseRfidId(): RfidId {
return { value: 0 };
}
export const RfidId: MessageFns<RfidId> = {
encode(message: RfidId, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.value !== 0) {
writer.uint32(8).uint32(message.value);
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): RfidId {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseRfidId();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 8) {
break;
}
message.value = reader.uint32();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): RfidId {
return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 };
},
toJSON(message: RfidId): unknown {
const obj: any = {};
if (message.value !== 0) {
obj.value = Math.round(message.value);
}
return obj;
},
create<I extends Exact<DeepPartial<RfidId>, I>>(base?: I): RfidId {
return RfidId.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<RfidId>, I>>(object: I): RfidId {
const message = createBaseRfidId();
message.value = object.value ?? 0;
return message;
},
};
function createBaseSyncResponse(): SyncResponse {
return { currentTime: 0, pendingChanges: false };
}
export const SyncResponse: MessageFns<SyncResponse> = {
encode(message: SyncResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.currentTime !== 0) {
writer.uint32(8).int64(message.currentTime);
}
if (message.pendingChanges !== false) {
writer.uint32(16).bool(message.pendingChanges);
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): SyncResponse {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseSyncResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 8) {
break;
}
message.currentTime = longToNumber(reader.int64());
continue;
}
case 2: {
if (tag !== 16) {
break;
}
message.pendingChanges = reader.bool();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): SyncResponse {
return {
currentTime: isSet(object.currentTime) ? globalThis.Number(object.currentTime) : 0,
pendingChanges: isSet(object.pendingChanges) ? globalThis.Boolean(object.pendingChanges) : false,
};
},
toJSON(message: SyncResponse): unknown {
const obj: any = {};
if (message.currentTime !== 0) {
obj.currentTime = Math.round(message.currentTime);
}
if (message.pendingChanges !== false) {
obj.pendingChanges = message.pendingChanges;
}
return obj;
},
create<I extends Exact<DeepPartial<SyncResponse>, I>>(base?: I): SyncResponse {
return SyncResponse.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<SyncResponse>, I>>(object: I): SyncResponse {
const message = createBaseSyncResponse();
message.currentTime = object.currentTime ?? 0;
message.pendingChanges = object.pendingChanges ?? false;
return message;
},
};
function createBaseSyncRequest(): SyncRequest {
return { lastSync: undefined, accessLogs: {} };
}
export const SyncRequest: MessageFns<SyncRequest> = {
encode(message: SyncRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.lastSync !== undefined) {
writer.uint32(8).int64(message.lastSync);
}
Object.entries(message.accessLogs).forEach(([key, value]) => {
SyncRequest_AccessLogsEntry.encode({ key: key as any, value }, writer.uint32(18).fork()).join();
});
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): SyncRequest {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseSyncRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 8) {
break;
}
message.lastSync = longToNumber(reader.int64());
continue;
}
case 2: {
if (tag !== 18) {
break;
}
const entry2 = SyncRequest_AccessLogsEntry.decode(reader, reader.uint32());
if (entry2.value !== undefined) {
message.accessLogs[entry2.key] = entry2.value;
}
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): SyncRequest {
return {
lastSync: isSet(object.lastSync) ? globalThis.Number(object.lastSync) : undefined,
accessLogs: isObject(object.accessLogs)
? Object.entries(object.accessLogs).reduce<{ [key: number]: number }>((acc, [key, value]) => {
acc[globalThis.Number(key)] = Number(value);
return acc;
}, {})
: {},
};
},
toJSON(message: SyncRequest): unknown {
const obj: any = {};
if (message.lastSync !== undefined) {
obj.lastSync = Math.round(message.lastSync);
}
if (message.accessLogs) {
const entries = Object.entries(message.accessLogs);
if (entries.length > 0) {
obj.accessLogs = {};
entries.forEach(([k, v]) => {
obj.accessLogs[k] = Math.round(v);
});
}
}
return obj;
},
create<I extends Exact<DeepPartial<SyncRequest>, I>>(base?: I): SyncRequest {
return SyncRequest.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<SyncRequest>, I>>(object: I): SyncRequest {
const message = createBaseSyncRequest();
message.lastSync = object.lastSync ?? undefined;
message.accessLogs = Object.entries(object.accessLogs ?? {}).reduce<{ [key: number]: number }>(
(acc, [key, value]) => {
if (value !== undefined) {
acc[globalThis.Number(key)] = globalThis.Number(value);
}
return acc;
},
{},
);
return message;
},
};
function createBaseSyncRequest_AccessLogsEntry(): SyncRequest_AccessLogsEntry {
return { key: 0, value: 0 };
}
export const SyncRequest_AccessLogsEntry: MessageFns<SyncRequest_AccessLogsEntry> = {
encode(message: SyncRequest_AccessLogsEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.key !== 0) {
writer.uint32(8).uint64(message.key);
}
if (message.value !== 0) {
writer.uint32(16).uint32(message.value);
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): SyncRequest_AccessLogsEntry {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseSyncRequest_AccessLogsEntry();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 8) {
break;
}
message.key = longToNumber(reader.uint64());
continue;
}
case 2: {
if (tag !== 16) {
break;
}
message.value = reader.uint32();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): SyncRequest_AccessLogsEntry {
return {
key: isSet(object.key) ? globalThis.Number(object.key) : 0,
value: isSet(object.value) ? globalThis.Number(object.value) : 0,
};
},
toJSON(message: SyncRequest_AccessLogsEntry): unknown {
const obj: any = {};
if (message.key !== 0) {
obj.key = Math.round(message.key);
}
if (message.value !== 0) {
obj.value = Math.round(message.value);
}
return obj;
},
create<I extends Exact<DeepPartial<SyncRequest_AccessLogsEntry>, I>>(base?: I): SyncRequest_AccessLogsEntry {
return SyncRequest_AccessLogsEntry.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<SyncRequest_AccessLogsEntry>, I>>(object: I): SyncRequest_AccessLogsEntry {
const message = createBaseSyncRequest_AccessLogsEntry();
message.key = object.key ?? 0;
message.value = object.value ?? 0;
return message;
},
};
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
export type DeepPartial<T> = T extends Builtin ? T
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin ? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
function longToNumber(int64: { toString(): string }): number {
const num = globalThis.Number(int64.toString());
if (num > globalThis.Number.MAX_SAFE_INTEGER) {
throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
}
if (num < globalThis.Number.MIN_SAFE_INTEGER) {
throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
}
return num;
}
function isObject(value: any): boolean {
return typeof value === "object" && value !== null;
}
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}
export interface MessageFns<T> {
encode(message: T, writer?: BinaryWriter): BinaryWriter;
decode(input: BinaryReader | Uint8Array, length?: number): T;
fromJSON(object: any): T;
toJSON(message: T): unknown;
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
}