// WriteTo writes the message to a stream of messages in the style defined
// by RFC-5425. (It does not implement the TLS stuff described in the RFC, just
// the length delimiting.
500299
func (m Message) WriteTo(w io.Writer) (int64, error) {
	b, err := m.MarshalBinary()
	if err != nil {
		return 0, err
	}
	n, err := fmt.Fprintf(w, "%d %s", len(b), b)
	return int64(n), err
}
1108482
func (out *RAMOutputStream) WriteTo(output util.DataOutput) error {
	err := out.Flush()
	if err != nil {
		return err
	}
	end := out.file.length
	pos := int64(0)
	buffer := 0
	for pos < end {
		length := BUFFER_SIZE
		nextPos := pos + int64(length)
		if nextPos > end { // at the last buffer
			length = int(end - pos)
		}
		err = output.WriteBytes(out.file.Buffer(buffer)[:length])
		if err != nil {
			return err
		}
		buffer++
		pos = nextPos
	}
	return nil
}
95075
func (q *PacketQueue) WriteTo(w io.Writer) (int64, error) {
	var buf bytes.Buffer
	_, err := q.Properties.WriteTo(&buf)
	if err != nil {
		return 0, err
	}

	return encoding.WriteTo(w, q.Queue, q.Port,
		uint16(buf.Len()+packetQueueLen), pad6{}, buf.Bytes())
}
1135455
func (f *FlowStatsRequest) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, f.Table, pad3{}, f.OutPort,
		f.OutGroup, pad4{}, f.Cookie, f.CookieMask, &f.Match,
	)
}
413197
func (s RawString) WriteTo(w Writer) error {
	return RawByteSlice(s).WriteTo(w)
}
1106630
func (s String) WriteTo(w Writer) error {
	return ByteSlice(s).WriteTo(w)
}
389794
func (b *ByteBuffer) WriteTo(w io.Writer) (int64, error) {
	n, err := w.Write(b.B)
	return int64(n), err
}
718676
func (c *Config) WriteTo(w io.Writer) (int64, error) {
	return 0, toml.NewEncoder(w).Encode(c)
}
783158
func (dec *declaration) WriteTo(w io.Writer) (int64, error) {
	return dec.writeTo(w, nil)
}
100147
func (q *QueuePropMinRate) WriteTo(w io.Writer) (int64, error) {
	header := queueProp{q.Type(), queuePropLen}
	return encoding.WriteTo(w, header, pad4{}, q.Rate, pad6{})
}
70048
func (i *InstructionWriteMetadata) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, instruction{i.Type(), 24},
		pad4{}, i.Metadata, i.MetadataMask)
}
75773
func (e *Error) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, e.Type, e.Code, e.Data)
}
748362
func (er *EchoRequest) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, er.Data)
}
224622
func (m *MeterBandExperimenter) WriteTo(w io.Writer) (int64, error) {
	header := meterBand{m.Type(), meterBandLen}
	return encoding.WriteTo(w, header, m.Rate,
		m.BurstSize, m.Experimenter)
}
493312
func (u UnkDic) WriteTo(w io.Writer) (n int64, err error) {
	size, err := writeMap(w, u.UnkIndex)
	if err != nil {
		return n, err
	}
	n += size
	size, err = writeMap(w, u.UnkIndexDup)
	if err != nil {
		return n, err
	}
	n += size

	var buf bytes.Buffer
	enc := gob.NewEncoder(&buf)
	if err := enc.Encode(u.UnkMorphs); err != nil {
		return n, err
	}
	size, err = buf.WriteTo(w)
	if err != nil {
		return n, err
	}
	n += size
	if err := enc.Encode(u.UnkContents); err != nil {
		return n, err
	}
	size, err = buf.WriteTo(w)
	if err != nil {
		return n, err
	}
	n += size

	return n, nil
}
721233
func (h *Header) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, *h)
}
1298789
func (p *PortStats) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, p.PortNo, pad4{}, p.RxPackets,
		p.TxPackets, p.RxBytes, p.TxBytes, p.RxDropped, p.TxDropped,
		p.RxErrors, p.TxErrors, p.RxFrameErr, p.RxOverErr, p.RxCrcErr,
		p.Collisions, p.DurationSec, p.DurationNSec,
	)
}