Interface BinaryFormat

BinaryFormat is the contract for serializing messages to and from binary data. Implementations may be specific to a proto syntax, and can be reflection based, or delegate to speed optimized generated code.

interface BinaryFormat {
    discardUnknownFields(message): void;
    listUnknownFields(message): readonly {
        data: Uint8Array;
        no: number;
        wireType: WireType;
    }[];
    makeReadOptions(options?): Readonly<BinaryReadOptions>;
    makeWriteOptions(options?): Readonly<BinaryWriteOptions>;
    onUnknownField(message, no, wireType, data): void;
    readField(target, reader, field, wireType, options): void;
    readMessage(message, reader, lengthOrEndTagFieldNo, options, delimitedMessageEncoding?): void;
    writeField(field, value, writer, options): void;
    writeMessage(message, writer, options): void;
    writeUnknownFields(message, writer): void;
}

Methods

  • Discard unknown fields for the given message.

    Parameters

    Returns void

  • Retrieve the unknown fields for the given message.

    Unknown fields are well-formed protocol buffer serialized data for fields that the parserdoes not recognize.

    For more details see https://developers.google.com/protocol-buffers/docs/proto3#unknowns

    Parameters

    Returns readonly {
        data: Uint8Array;
        no: number;
        wireType: WireType;
    }[]

  • Provide options for parsing binary data.

    Parameters

    Returns Readonly<BinaryReadOptions>

  • Provide options for serializing binary data.

    Parameters

    Returns Readonly<BinaryWriteOptions>

  • Store an unknown field for the given message. The parser will use this method if it does not recognize a field, unless the option readUnknownFields has been disabled.

    Parameters

    Returns void

  • Parse a field from binary data, and store it in the given target.

    The target must be an initialized message object, with oneof groups, repeated fields and maps already present.

    Parameters

    Returns void

  • Parse a message from binary data, merging fields.

    Supports two message encodings:

    • length-prefixed: delimitedMessageEncoding is false or omitted, and lengthOrEndTagFieldNo is the expected length of the message in the reader.
    • delimited: delimitedMessageEncoding is true, and lengthOrEndTagFieldNo is the field number in a tag with wire type end-group signalling the end of the message in the reader.

    delimitedMessageEncoding is optional for backwards compatibility.

    Parameters

    Returns void

  • Serialize a field value to binary data.

    The value must be an array for repeated fields, a record object for map fields. Only selected oneof fields should be passed to this method.

    Parameters

    Returns void

  • Serialize a message to binary data.

    Parameters

    Returns void

  • Retrieve the unknown fields for the given message and write them to the given writer. This method is called when a message is serialized, so the fields that are unknown to the parser persist through a round trip.

    Parameters

    Returns void