// @generated by protobuf-ts 2.9.0
// @generated from protobuf file "link.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 link is a pointer from one piece to another.
*
* @generated from protobuf message pb.Link
*/
export interface Link {
/**
* The CID of the linked piece.
*
* @generated from protobuf field: string cid = 1;
*/
cid: string;
/**
* The size of the payload of the linked piece.
*
* @generated from protobuf field: uint64 size = 2;
*/
size: bigint;
/**
* The name of the linked piece, in the context of the linking piece.
*
* @generated from protobuf field: string name = 3;
*/
name: string;
}
// @generated message type with reflection information, may provide speed optimized methods
class Link$Type extends MessageType {
constructor() {
super("pb.Link", [
{ no: 1, name: "cid", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 2, name: "size", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 3, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
]);
}
create(value?: PartialMessage): Link {
const message = { cid: "", size: 0n, name: "" };
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?: Link): Link {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* string cid */ 1:
message.cid = reader.string();
break;
case /* uint64 size */ 2:
message.size = reader.uint64().toBigInt();
break;
case /* string name */ 3:
message.name = reader.string();
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: Link, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* string cid = 1; */
if (message.cid !== "")
writer.tag(1, WireType.LengthDelimited).string(message.cid);
/* uint64 size = 2; */
if (message.size !== 0n)
writer.tag(2, WireType.Varint).uint64(message.size);
/* string name = 3; */
if (message.name !== "")
writer.tag(3, WireType.LengthDelimited).string(message.name);
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message pb.Link
*/
export const Link = new Link$Type();