golang_protobuf_extensions: github.com/matttproud/golang_protobuf_extensions/pbutil Index | Files

package pbutil

import "github.com/matttproud/golang_protobuf_extensions/pbutil"

Package pbutil provides record length-delimited Protocol Buffer streaming.

Index

Package Files

decode.go doc.go encode.go

func ReadDelimited Uses

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 Uses

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.

Package pbutil imports 4 packages (graph) and is imported by 21 packages. Updated 2016-07-25. Refresh now. Tools for package owners.