pbutil

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2015 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package pbutil provides record length-delimited Protocol Buffer streaming.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadDelimited

func ReadDelimited(r io.Reader, m proto.Message) (n int, err error)

ReadDelimited decodes a message from the provided length-delimited stream, where the length is encoded as 32-bit varint prefix to the message body. It returns the total number of bytes read and any applicable error. This is roughly equivalent to the companion Java API's MessageLite#parseDelimitedFrom. As per the reader contract, this function calls r.Read repeatedly as required until exactly one message including its prefix is read and decoded (or an error has occurred). The function never reads more bytes from the stream than required. The function never returns an error if a message has been read and decoded correctly, even if the end of the stream has been reached in doing so. In that case, any subsequent calls return (0, io.EOF).

func WriteDelimited

func WriteDelimited(w io.Writer, m proto.Message) (n int, err error)

WriteDelimited encodes and dumps a message to the provided writer prefixed with a 32-bit varint indicating the length of the encoded message, producing a length-delimited record stream, which can be used to chain together encoded messages of the same type together in a file. It returns the total number of bytes written and any applicable error. This is roughly equivalent to the companion Java API's MessageLite#writeDelimitedTo.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL