Copyright 2013 Matt T. Proud Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

package pbutil

import (
	
	

	
)
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.
func ( io.Writer,  proto.Message) ( int,  error) {
	,  := proto.Marshal()
	if  != nil {
		return 0, 
	}

	var  [binary.MaxVarintLen32]byte
	 := binary.PutUvarint([:], uint64(len()))

	,  := .Write([:])
	if  != nil {
		return , 
	}

	,  = .Write()
	return  + ,