Debian Codegraph @

node/@bufbuild/protobuf/dist/esm/to-binary.d.ts

raw
1 import type { MessageShape } from "./types.js";
2 import { BinaryWriter } from "./wire/binary-encoding.js";
3 import { type DescField, type DescMessage } from "./descriptors.js";
4 import type { ReflectMessage } from "./reflect/index.js";
5 /**
6 * Options for serializing to binary data.
7 *
8 * V1 also had the option `readerFactory` for using a custom implementation to
9 * encode to binary.
10 */
11 export interface BinaryWriteOptions {
12 /**
13 * Include unknown fields in the serialized output? The default behavior
14 * is to retain unknown fields and include them in the serialized output.
15 *
16 * For more details see https://developers.google.com/protocol-buffers/docs/proto3#unknowns
17 */
18 writeUnknownFields: boolean;
19 }
20 export declare function toBinary<Desc extends DescMessage>(schema: Desc, message: MessageShape<Desc>, options?: Partial<BinaryWriteOptions>): Uint8Array<ArrayBuffer>;
21 /**
22 * Write a single field to binary format, if it is set. Used to serialize
23 * extensions: extensions always have explicit presence, so an extension
24 * value that was just set on the container is always written.
25 *
26 * @private
27 */
28 export declare function writeField(writer: BinaryWriter, opts: BinaryWriteOptions, msg: ReflectMessage, field: DescField): void;