Skip to main content
Module

x/pbkit/generated/messages/google/protobuf/ServiceDescriptorProto.ts

Protobuf toolkit for modern web development
Go to Latest
File
import { Type as MethodDescriptorProto, encodeJson as encodeJson_1, decodeJson as decodeJson_1, encodeBinary as encodeBinary_1, decodeBinary as decodeBinary_1,} from "./MethodDescriptorProto.ts";import { Type as ServiceOptions, encodeJson as encodeJson_2, decodeJson as decodeJson_2, encodeBinary as encodeBinary_2, decodeBinary as decodeBinary_2,} from "./ServiceOptions.ts";import { tsValueToJsonValueFns, jsonValueToTsValueFns,} from "../../../../core/runtime/json/scalar.ts";import { WireMessage, WireType,} 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 { export type ServiceDescriptorProto = { name?: string; method: MethodDescriptorProto[]; options?: ServiceOptions; }}export type Type = $.google.protobuf.ServiceDescriptorProto;
export function getDefaultValue(): $.google.protobuf.ServiceDescriptorProto { return { name: "", method: [], options: undefined, };}
export function createValue(partialValue: Partial<$.google.protobuf.ServiceDescriptorProto>): $.google.protobuf.ServiceDescriptorProto { return { ...getDefaultValue(), ...partialValue, };}
export function encodeJson(value: $.google.protobuf.ServiceDescriptorProto): unknown { const result: any = {}; if (value.name !== undefined) result.name = tsValueToJsonValueFns.string(value.name); result.method = value.method.map(value => encodeJson_1(value)); if (value.options !== undefined) result.options = encodeJson_2(value.options); return result;}
export function decodeJson(value: any): $.google.protobuf.ServiceDescriptorProto { const result = getDefaultValue(); if (value.name !== undefined) result.name = jsonValueToTsValueFns.string(value.name); result.method = value.method?.map((value: any) => decodeJson_1(value)) ?? []; if (value.options !== undefined) result.options = decodeJson_2(value.options); return result;}
export function encodeBinary(value: $.google.protobuf.ServiceDescriptorProto): Uint8Array { const result: WireMessage = []; if (value.name !== undefined) { const tsValue = value.name; result.push( [1, tsValueToWireValueFns.string(tsValue)], ); } for (const tsValue of value.method) { result.push( [2, { type: WireType.LengthDelimited as const, value: encodeBinary_1(tsValue) }], ); } if (value.options !== undefined) { const tsValue = value.options; result.push( [3, { type: WireType.LengthDelimited as const, value: encodeBinary_2(tsValue) }], ); } return serialize(result);}
export function decodeBinary(binary: Uint8Array): $.google.protobuf.ServiceDescriptorProto { 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.string(wireValue); if (value === undefined) break field; result.name = value; } collection: { const wireValues = wireMessage.filter(([fieldNumber]) => fieldNumber === 2).map(([, wireValue]) => wireValue); const value = wireValues.map((wireValue) => wireValue.type === WireType.LengthDelimited ? decodeBinary_1(wireValue.value) : undefined).filter(x => x !== undefined); if (!value.length) break collection; result.method = value as any; } field: { const wireValue = wireFields.get(3); if (wireValue === undefined) break field; const value = wireValue.type === WireType.LengthDelimited ? decodeBinary_2(wireValue.value) : undefined; if (value === undefined) break field; result.options = value; } return result;}