Interface ProtobufStream<Stream>

Convenience methods for working with protobuf streams

Type Parameters

  • Stream = unknown

Hierarchy

  • ProtobufStream

Properties

pb: (<T>(proto: {
    decode: Decoder<T>;
    encode: Encoder<T>;
}) => MessageStream<T, Stream>)

Type declaration

    • <T>(proto: {
          decode: Decoder<T>;
          encode: Encoder<T>;
      }): MessageStream<T, Stream>
    • Returns an object with read/write methods for operating on one specific type of protobuf message

      Type Parameters

      • T

      Parameters

      Returns MessageStream<T, Stream>

read: ((bytes?: number) => Promise<Uint8ArrayList>)

Type declaration

readLP: (() => Promise<Uint8ArrayList>)

Type declaration

readPB: (<T>(proto: {
    decode: Decoder<T>;
}) => Promise<T>)

Type declaration

    • <T>(proto: {
          decode: Decoder<T>;
      }): Promise<T>
    • Read the next length-prefixed byte array from the stream and decode it as the passed protobuf format

      Type Parameters

      • T

      Parameters

      Returns Promise<T>

unwrap: (() => Stream)

Type declaration

    • (): Stream
    • Returns the underlying stream

      Returns Stream

write: ((input: Uint8Array | Uint8ArrayList) => void)

Type declaration

writeLP: ((input: Uint8Array | Uint8ArrayList) => void)

Type declaration

writePB: (<T>(data: T, proto: {
    encode: Encoder<T>;
}) => void)

Type declaration

    • <T>(data: T, proto: {
          encode: Encoder<T>;
      }): void
    • Encode the passed object as a protobuf message and write it's length-prefixed bytes tot he stream

      Type Parameters

      • T

      Parameters

      Returns void