// WriteTo implements io.WriterTo interface. It serializes instruction
// used to write actions into the wire format.
433791
func (i *InstructionWriteActions) WriteTo(w io.Writer) (int64, error) {
	return writeInstructionActions(w, i.Type(), i.Actions)
}
1148670
func (c *Command) WriteTo(w io.Writer) (int64, error) {
	var total int64
	var buf [4]byte

	n, err := w.Write(c.Name)
	total += int64(n)
	if err != nil {
		return total, err
	}

	for _, param := range c.Params {
		n, err := w.Write(byteSpace)
		total += int64(n)
		if err != nil {
			return total, err
		}
		n, err = w.Write(param)
		total += int64(n)
		if err != nil {
			return total, err
		}
	}

	n, err = w.Write(byteNewLine)
	total += int64(n)
	if err != nil {
		return total, err
	}

	if c.Body != nil {
		bufs := buf[:]
		binary.BigEndian.PutUint32(bufs, uint32(len(c.Body)))
		n, err := w.Write(bufs)
		total += int64(n)
		if err != nil {
			return total, err
		}
		n, err = w.Write(c.Body)
		total += int64(n)
		if err != nil {
			return total, err
		}
	}

	return total, nil
}
1264599
func (t Time) WriteTo(w Writer) error {
	bytes, err := time.Time(t).MarshalBinary()
	if err != nil {
		return errorsp.WithStacks(err)
	}
	return errorsp.WithStacks(ByteSlice(bytes).WriteTo(w))
}
32201
func (b *base) WriteTo(w io.Writer) (int64, error) {
	// Create a byte buffer.
	var bf bytes.Buffer

	// Write the Packet data to the buffer.
	bf.Write(b.fixedHeader)
	bf.Write(b.variableHeader)
	bf.Write(b.payload)

	// Write the buffered data to the writer.
	n, err := w.Write(bf.Bytes())

	// Return the result.
	return int64(n), err
}
829328
func (sc *SwitchConfig) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, *sc)
}
860708
func (b Bool) WriteTo(w io.Writer) (int64, error) {
	written, err := fmt.Fprintf(w, "%t", b)
	return int64(written), err
}
1098072
func (sf *scriptFlags) WriteTo(w io.Writer) (int64, error) {
	var b [8]byte
	if sf.hasScript {
		b[0] |= 1 << 1
	}
	if sf.change {
		b[0] |= 1 << 5
	}
	if sf.unsynced {
		b[0] |= 1 << 6
	}
	if sf.partialSync {
		b[0] |= 1 << 7
	}

	n, err := w.Write(b[:])
	return int64(n), err
}
953128
func (msg Message) WriteTo(w io.Writer) (int64, error) {
	var bytesWritten int

	nw, err := fmt.Fprintf(w, "%s%s", msg.Address, msg.Typetags())
	if err != nil {
		return 0, err
	}
	bytesWritten += nw

	for _, a := range msg.Arguments {
		nw, err := a.WriteTo(w)
		if err != nil {
			return 0, err
		}
		bytesWritten += int(nw)
	}

	return int64(bytesWritten), nil
}
44778
func (f *FlowRemoved) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, f.Cookie, f.Priority, f.Reason,
		f.Table, f.DurationSec, f.DurationNSec, f.IdleTimeout,
		f.HardTimeout, f.PacketCount, f.ByteCount, &f.Match,
	)
}
1235831
func (e *Experimenter) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, e.Experimenter, e.ExpType)
}
70048
func (i *InstructionWriteMetadata) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, instruction{i.Type(), 24},
		pad4{}, i.Metadata, i.MetadataMask)
}
339806
func (b *Buffer) WriteTo(w io.Writer) (int64, error) {
	version := b.preOp()
	n, err := b.buf.WriteTo(w)
	b.postOp(version)
	return n, err
}
1018969
func (arr *ByteArray) WriteTo(w io.Writer) (n int64, err error) {
	var nn int64

	// Write length-prefix
	var length = types.Int32(len(arr.Value))
	nn, err = length.WriteTo(w)
	if err != nil {
		return
	}
	n += nn

	// Then write byte array
	for _, elem := range arr.Value {
		nn, err = elem.WriteTo(w)
		if err != nil {
			return
		}
		n += nn
	}

	return
}
294999
func (e *End) WriteTo(w io.Writer) (n int64, err error) {
	var tid byte

	err = binary.Write(w, binary.BigEndian, &tid)
	if err != nil {
		return
	}
	n = 1
	return
}
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
}
463840
func (s String) WriteTo(w io.Writer) (int64, error) {
	written, err := fmt.Fprintf(w, "%s", s)
	return int64(written), err
}
1172198
func (sel *selector) WriteTo(w io.Writer) (int64, error) {
	return sel.writeTo(w, nil)
}