-
Notifications
You must be signed in to change notification settings - Fork 22
/
Version.ts
125 lines (118 loc) · 3.82 KB
/
Version.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import {
tsValueToJsonValueFns,
jsonValueToTsValueFns,
} from "../../../../../core/runtime/json/scalar.ts";
import {
WireMessage,
} from "../../../../../core/runtime/wire/index.ts";
import {
default as serialize,
} from "../../../../../core/runtime/wire/serialize.ts";
import {
tsValueToWireValueFns,
wireValueToTsValueFns,
} from "../../../../../core/runtime/wire/scalar.ts";
import {
default as deserialize,
} from "../../../../../core/runtime/wire/deserialize.ts";
export declare namespace $.google.protobuf.compiler {
export type Version = {
major?: number;
minor?: number;
patch?: number;
suffix?: string;
}
}
export type Type = $.google.protobuf.compiler.Version;
export function getDefaultValue(): $.google.protobuf.compiler.Version {
return {
major: 0,
minor: 0,
patch: 0,
suffix: "",
};
}
export function createValue(partialValue: Partial<$.google.protobuf.compiler.Version>): $.google.protobuf.compiler.Version {
return {
...getDefaultValue(),
...partialValue,
};
}
export function encodeJson(value: $.google.protobuf.compiler.Version): unknown {
const result: any = {};
if (value.major !== undefined) result.major = tsValueToJsonValueFns.int32(value.major);
if (value.minor !== undefined) result.minor = tsValueToJsonValueFns.int32(value.minor);
if (value.patch !== undefined) result.patch = tsValueToJsonValueFns.int32(value.patch);
if (value.suffix !== undefined) result.suffix = tsValueToJsonValueFns.string(value.suffix);
return result;
}
export function decodeJson(value: any): $.google.protobuf.compiler.Version {
const result = getDefaultValue();
if (value.major !== undefined) result.major = jsonValueToTsValueFns.int32(value.major);
if (value.minor !== undefined) result.minor = jsonValueToTsValueFns.int32(value.minor);
if (value.patch !== undefined) result.patch = jsonValueToTsValueFns.int32(value.patch);
if (value.suffix !== undefined) result.suffix = jsonValueToTsValueFns.string(value.suffix);
return result;
}
export function encodeBinary(value: $.google.protobuf.compiler.Version): Uint8Array {
const result: WireMessage = [];
if (value.major !== undefined) {
const tsValue = value.major;
result.push(
[1, tsValueToWireValueFns.int32(tsValue)],
);
}
if (value.minor !== undefined) {
const tsValue = value.minor;
result.push(
[2, tsValueToWireValueFns.int32(tsValue)],
);
}
if (value.patch !== undefined) {
const tsValue = value.patch;
result.push(
[3, tsValueToWireValueFns.int32(tsValue)],
);
}
if (value.suffix !== undefined) {
const tsValue = value.suffix;
result.push(
[4, tsValueToWireValueFns.string(tsValue)],
);
}
return serialize(result);
}
export function decodeBinary(binary: Uint8Array): $.google.protobuf.compiler.Version {
const result = getDefaultValue();
const wireMessage = deserialize(binary);
const wireFields = new Map(wireMessage);
field: {
const wireValue = wireFields.get(1);
if (wireValue === undefined) break field;
const value = wireValueToTsValueFns.int32(wireValue);
if (value === undefined) break field;
result.major = value;
}
field: {
const wireValue = wireFields.get(2);
if (wireValue === undefined) break field;
const value = wireValueToTsValueFns.int32(wireValue);
if (value === undefined) break field;
result.minor = value;
}
field: {
const wireValue = wireFields.get(3);
if (wireValue === undefined) break field;
const value = wireValueToTsValueFns.int32(wireValue);
if (value === undefined) break field;
result.patch = value;
}
field: {
const wireValue = wireFields.get(4);
if (wireValue === undefined) break field;
const value = wireValueToTsValueFns.string(wireValue);
if (value === undefined) break field;
result.suffix = value;
}
return result;
}