// @generated by protobuf-ts 2.9.0 // @generated from protobuf file "tag.proto" (package "pb", syntax proto3) // tslint:disable import type { BinaryWriteOptions } from "@protobuf-ts/runtime"; import type { IBinaryWriter } from "@protobuf-ts/runtime"; import { WireType } from "@protobuf-ts/runtime"; import type { BinaryReadOptions } from "@protobuf-ts/runtime"; import type { IBinaryReader } from "@protobuf-ts/runtime"; import { UnknownFieldHandler } from "@protobuf-ts/runtime"; import type { PartialMessage } from "@protobuf-ts/runtime"; import { reflectionMergePartial } from "@protobuf-ts/runtime"; import { MESSAGE_TYPE } from "@protobuf-ts/runtime"; import { MessageType } from "@protobuf-ts/runtime"; /** * * A tag is a `key/value` attribute attached to a piece. * * Tags can be used to search or filter pieces in storage. If search is not needed, disable it * using the `searchable` field. * * Specific tags are used to implement different higher protocols, such as a file system. * Each key should start with a prefix indicating which protocol or application relies on it. Below is a non-exhaustive table of known tag keys: * * Tag Key | Description * ------------ | ----------- * content-type | The MIME type of the payload of a piece or file. This is returned by the CDN web interface as HTTP Content-Type. * file-* | Tags to implement a filesystem over object storage. Example: `file-path` * kv-* | Tags to implement a key/value store over object storage. * enc-* | Tags to organize data encryption and data sharing keys. * * Below is the structure of a tag: * * @generated from protobuf message pb.Tag */ export interface Tag { /** * The key of the tag. It is usually a UTF-8 string, but it may be any data. * * @generated from protobuf field: bytes key = 1; */ key: Uint8Array; /** * The value of the tag for this key. The value should be interpreted based on the key. * * @generated from protobuf field: bytes value = 2; */ value: Uint8Array; /** * Whether this tag is searchable or not. Yes by default. * * @generated from protobuf field: pb.SearchType searchable = 3; */ searchable: SearchType; } /** * How can this tag be searched. * * @generated from protobuf enum pb.SearchType */ export enum SearchType { /** * RANGE tags should be indexed by nodes into their database to allow efficient queries on a key * for an exact value or a range of values. This is the default. * * @generated from protobuf enum value: RANGE = 0; */ RANGE = 0, /** * NOT_SEARCHABLE tags should not be indexed. This option should be set when possible to save * node space and speed. * * @generated from protobuf enum value: NOT_SEARCHABLE = 1; */ NOT_SEARCHABLE = 1 } // @generated message type with reflection information, may provide speed optimized methods class Tag$Type extends MessageType { constructor() { super("pb.Tag", [ { no: 1, name: "key", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 2, name: "value", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 3, name: "searchable", kind: "enum", T: () => ["pb.SearchType", SearchType] } ]); } create(value?: PartialMessage): Tag { const message = { key: new Uint8Array(0), value: new Uint8Array(0), searchable: 0 }; globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) reflectionMergePartial(this, message, value); return message; } internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Tag): Tag { let message = target ?? this.create(), end = reader.pos + length; while (reader.pos < end) { let [fieldNo, wireType] = reader.tag(); switch (fieldNo) { case /* bytes key */ 1: message.key = reader.bytes(); break; case /* bytes value */ 2: message.value = reader.bytes(); break; case /* pb.SearchType searchable */ 3: message.searchable = reader.int32(); break; default: let u = options.readUnknownField; if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); let d = reader.skip(wireType); if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); } } return message; } internalBinaryWrite(message: Tag, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { /* bytes key = 1; */ if (message.key.length) writer.tag(1, WireType.LengthDelimited).bytes(message.key); /* bytes value = 2; */ if (message.value.length) writer.tag(2, WireType.LengthDelimited).bytes(message.value); /* pb.SearchType searchable = 3; */ if (message.searchable !== 0) writer.tag(3, WireType.Varint).int32(message.searchable); let u = options.writeUnknownFields; if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); return writer; } } /** * @generated MessageType for protobuf message pb.Tag */ export const Tag = new Tag$Type();