UNPKG

@xmtp/proto

Version:

Protobuf client and generated classes for GRPC API

165 lines (164 loc) 5.61 kB
// Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v1.181.2 // protoc v3.21.12 // source: mls/message_contents/oneshot.proto /* eslint-disable */ import Long from "long"; import _m0 from "protobufjs/minimal"; export const protobufPackage = "xmtp.mls.message_contents"; function createBaseOneshotMessage() { return { readdRequest: undefined }; } export const OneshotMessage = { encode(message, writer = _m0.Writer.create()) { if (message.readdRequest !== undefined) { ReaddRequest.encode(message.readdRequest, writer.uint32(10).fork()).ldelim(); } return writer; }, decode(input, length) { const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseOneshotMessage(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.readdRequest = ReaddRequest.decode(reader, reader.uint32()); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { readdRequest: isSet(object.readdRequest) ? ReaddRequest.fromJSON(object.readdRequest) : undefined }; }, toJSON(message) { const obj = {}; if (message.readdRequest !== undefined) { obj.readdRequest = ReaddRequest.toJSON(message.readdRequest); } return obj; }, create(base) { return OneshotMessage.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseOneshotMessage(); message.readdRequest = (object.readdRequest !== undefined && object.readdRequest !== null) ? ReaddRequest.fromPartial(object.readdRequest) : undefined; return message; }, }; function createBaseReaddRequest() { return { groupId: new Uint8Array(0), latestCommitSequenceId: Long.UZERO }; } export const ReaddRequest = { encode(message, writer = _m0.Writer.create()) { if (message.groupId.length !== 0) { writer.uint32(10).bytes(message.groupId); } if (!message.latestCommitSequenceId.equals(Long.UZERO)) { writer.uint32(16).uint64(message.latestCommitSequenceId); } return writer; }, decode(input, length) { const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseReaddRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.groupId = reader.bytes(); continue; case 2: if (tag !== 16) { break; } message.latestCommitSequenceId = reader.uint64(); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { groupId: isSet(object.groupId) ? bytesFromBase64(object.groupId) : new Uint8Array(0), latestCommitSequenceId: isSet(object.latestCommitSequenceId) ? Long.fromValue(object.latestCommitSequenceId) : Long.UZERO, }; }, toJSON(message) { const obj = {}; if (message.groupId.length !== 0) { obj.groupId = base64FromBytes(message.groupId); } if (!message.latestCommitSequenceId.equals(Long.UZERO)) { obj.latestCommitSequenceId = (message.latestCommitSequenceId || Long.UZERO).toString(); } return obj; }, create(base) { return ReaddRequest.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseReaddRequest(); message.groupId = object.groupId ?? new Uint8Array(0); message.latestCommitSequenceId = (object.latestCommitSequenceId !== undefined && object.latestCommitSequenceId !== null) ? Long.fromValue(object.latestCommitSequenceId) : Long.UZERO; return message; }, }; function bytesFromBase64(b64) { if (globalThis.Buffer) { return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); for (let i = 0; i < bin.length; ++i) { arr[i] = bin.charCodeAt(i); } return arr; } } function base64FromBytes(arr) { if (globalThis.Buffer) { return globalThis.Buffer.from(arr).toString("base64"); } else { const bin = []; arr.forEach((byte) => { bin.push(globalThis.String.fromCharCode(byte)); }); return globalThis.btoa(bin.join("")); } } if (_m0.util.Long !== Long) { _m0.util.Long = Long; _m0.configure(); } function isSet(value) { return value !== null && value !== undefined; }