1package protobuf
2
3import "github.com/couchbase/indexing/secondary/transport"
4import "net"
5
6const (
7	LenOffset  int = 0
8	LenSize    int = 4
9	FlagOffset int = LenOffset + LenSize
10	FlagSize   int = 2
11	DataOffset int = FlagOffset + FlagSize
12)
13
14func EncodeAndWrite(conn net.Conn, buf []byte, r interface{}) (err error) {
15	var data []byte
16	data, err = ProtobufEncodeInBuf(r, buf[transport.MaxSendBufSize:][:0])
17	if err != nil {
18		return
19	}
20	flags := transport.TransportFlag(0).SetProtobuf()
21	err = transport.Send(conn, buf, flags, data, false)
22	return
23}
24