-
Notifications
You must be signed in to change notification settings - Fork 4
/
message.ts
96 lines (96 loc) · 3.02 KB
/
message.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 4.25.3
* source: message.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as pb_1 from "google-protobuf";
export class Message extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
fields?: string[];
tags?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("fields" in data && data.fields != undefined) {
this.fields = data.fields;
}
if ("tags" in data && data.tags != undefined) {
this.tags = data.tags;
}
}
}
get fields() {
return pb_1.Message.getFieldWithDefault(this, 1, []) as string[];
}
set fields(value: string[]) {
pb_1.Message.setField(this, 1, value);
}
get tags() {
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
}
set tags(value: string) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
fields?: string[];
tags?: string;
}): Message {
const message = new Message({});
if (data.fields != null) {
message.fields = data.fields;
}
if (data.tags != null) {
message.tags = data.tags;
}
return message;
}
toObject() {
const data: {
fields?: string[];
tags?: string;
} = {};
if (this.fields != null) {
data.fields = this.fields;
}
if (this.tags != null) {
data.tags = this.tags;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.fields.length)
writer.writeRepeatedString(1, this.fields);
if (this.tags.length)
writer.writeString(2, this.tags);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Message {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Message();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
pb_1.Message.addToRepeatedField(message, 1, reader.readString());
break;
case 2:
message.tags = reader.readString();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Message {
return Message.deserialize(bytes);
}
}