// @generated by protobuf-ts 2.9.0 // @generated from protobuf file "piece.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"; import { Link } from "./link"; import { Tag } from "./tag"; /** * * A piece is a container of data and metadata. * It is the smallest indivisible unit stored in DDC object storage. * * @generated from protobuf message pb.Piece */ export interface Piece { /** * The opaque payload carried by the piece. * * @generated from protobuf field: bytes data = 1; */ data: Uint8Array; /** * The ID of a bucket that contains the piece. * * @generated from protobuf field: uint32 bucketId = 2; */ bucketId: number; /** * A list of tags with which the piece may be searched. * There can be multiple tags with the same key. * * @generated from protobuf field: repeated pb.Tag tags = 3; */ tags: Tag[]; /** * A list of links to other pieces. * If this piece is interpreted as a file, the linked pieces make up the file content. * * @generated from protobuf field: repeated pb.Link links = 4; */ links: Link[]; } // @generated message type with reflection information, may provide speed optimized methods class Piece$Type extends MessageType { constructor() { super("pb.Piece", [ { no: 1, name: "data", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 2, name: "bucketId", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 3, name: "tags", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => Tag }, { no: 4, name: "links", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => Link } ]); } create(value?: PartialMessage): Piece { const message = { data: new Uint8Array(0), bucketId: 0, tags: [], links: [] }; 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?: Piece): Piece { let message = target ?? this.create(), end = reader.pos + length; while (reader.pos < end) { let [fieldNo, wireType] = reader.tag(); switch (fieldNo) { case /* bytes data */ 1: message.data = reader.bytes(); break; case /* uint32 bucketId */ 2: message.bucketId = reader.uint32(); break; case /* repeated pb.Tag tags */ 3: message.tags.push(Tag.internalBinaryRead(reader, reader.uint32(), options)); break; case /* repeated pb.Link links */ 4: message.links.push(Link.internalBinaryRead(reader, reader.uint32(), options)); 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: Piece, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { /* bytes data = 1; */ if (message.data.length) writer.tag(1, WireType.LengthDelimited).bytes(message.data); /* uint32 bucketId = 2; */ if (message.bucketId !== 0) writer.tag(2, WireType.Varint).uint32(message.bucketId); /* repeated pb.Tag tags = 3; */ for (let i = 0; i < message.tags.length; i++) Tag.internalBinaryWrite(message.tags[i], writer.tag(3, WireType.LengthDelimited).fork(), options).join(); /* repeated pb.Link links = 4; */ for (let i = 0; i < message.links.length; i++) Link.internalBinaryWrite(message.links[i], writer.tag(4, WireType.LengthDelimited).fork(), options).join(); let u = options.writeUnknownFields; if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); return writer; } } /** * @generated MessageType for protobuf message pb.Piece */ export const Piece = new Piece$Type();