// WriteTo writes captcha audio in WAVE format into the given io.Writer, and
// returns the number of bytes written and an error if any.
167835
func (a *Audio) WriteTo(w io.Writer) (n int64, err error) {
	// Calculate padded length of PCM chunk data.
	bodyLen := uint32(a.body.Len())
	paddedBodyLen := bodyLen
	if bodyLen%2 != 0 {
		paddedBodyLen++
	}
	totalLen := uint32(len(waveHeader)) - 4 + paddedBodyLen
	// Header.
	header := make([]byte, len(waveHeader)+4) // includes 4 bytes for chunk size
	copy(header, waveHeader)
	// Put the length of whole RIFF chunk.
	binary.LittleEndian.PutUint32(header[4:], totalLen)
	// Put the length of WAVE chunk.
	binary.LittleEndian.PutUint32(header[len(waveHeader):], bodyLen)
	// Write header.
	nn, err := w.Write(header)
	n = int64(nn)
	if err != nil {
		return
	}
	// Write data.
	n, err = a.body.WriteTo(w)
	n += int64(nn)
	if err != nil {
		return
	}
	// Pad byte if chunk length is odd.
	// (As header has even length, we can check if n is odd, not chunk).
	if bodyLen != paddedBodyLen {
		w.Write([]byte{0})
		n++
	}
	return
}
643479
func (h *authHeaderWriterTo) WriteTo(w io.Writer) (n int64, err error) {

	var (
		signedContent bytes.Buffer
		bytesWritten  int64
	)

	// Timestamp
	ts := jwt.TimeFunc().UTC().Unix()
	if err = binary.Write(&signedContent, byteOrder, timestamp(ts)); err != nil {
		return 0, err
	}

	// Token len
	tokenLen := len(h.token)
	// Check to see if it overflows uint16
	if int(tokenLength(tokenLen)) != tokenLen {
		return 0, ErrBadToken
	}

	// Token
	if err = binary.Write(&signedContent, byteOrder, h.token); err != nil {
		return 0, err
	}

	// Payload len
	payloadLen := len(h.payload)
	// Check to see if it overflows uint16
	if int(payloadLength(payloadLen)) != payloadLen {
		return 0, ErrPayloadTooLarge
	}
	if err = binary.Write(&signedContent, byteOrder, payloadLength(payloadLen)); err != nil {
		return 0, err
	}

	// Payload
	if err = binary.Write(&signedContent, byteOrder, h.payload); err != nil {
		return 0, err
	}

	// Sign the contents of the buffer
	sig, err := h.signer.Sign(signedContent.Bytes())
	if err != nil {
		return 0, err
	}

	// Write the magic number
	err = binary.Write(w, byteOrder, MagicNumber)
	if err != nil {
		return n, err
	}
	n += int64(binary.Size(MagicNumber))

	// Write the protocol version
	err = binary.Write(w, byteOrder, ProtocolVersion)
	if err != nil {
		return n, err
	}
	n += int64(binary.Size(ProtocolVersion))

	// Write the length of everything left except the payload len and payload
	allLen := uint32(tokenLen + 8)
	err = binary.Write(w, byteOrder, allLen)
	if err != nil {
		return n, err
	}

	// Write the signature
	err = binary.Write(w, byteOrder, sig)
	if err != nil {
		return n, err
	}
	n += int64(binary.Size(sig))

	// Write the buffer contents (timestamp, token, payloadlen, payload)
	bytesWritten, err = signedContent.WriteTo(w)
	if err != nil {
		return n, err
	}
	n += bytesWritten

	return n, nil
}
796873
func (g *GroupMod) WriteTo(w io.Writer) (int64, error) {
	n, err := encoding.WriteTo(w, g.Command, g.Type, pad1{}, g.Group)
	if err != nil {
		return n, err
	}

	nn, err := encoding.WriteSliceTo(w, g.Buckets)
	return n + nn, err
}
350792
func (s Slice) WriteTo(w io.Writer) (n int64, err error) {
	nWrite, err := w.Write(s)
	return int64(nWrite), err
}
403342
func (s *SwitchFeatures) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w,
		s.DatapathID, s.NumBuffers, s.NumTables, s.AuxiliaryID,
		pad2{}, s.Capabilities, s.Reserved)
}
1204914
func (op *op) WriteTo(w io.Writer) (n int64, err error) {
	buf := make([]byte, op.size())

	// Write type and value.
	buf[0] = byte(op.typ)
	if op.typ <= 1 {
		binary.LittleEndian.PutUint64(buf[1:9], op.value)
	} else {
		binary.LittleEndian.PutUint64(buf[1:9], uint64(len(op.values)))
		p := 13 // start of values (skip 4 for checksum)
		for _, v := range op.values {
			binary.LittleEndian.PutUint64(buf[p:p+8], v)
			p += 8
		}
	}

	// Add checksum at the end.
	h := fnv.New32a()
	_, _ = h.Write(buf[0:9])
	_, _ = h.Write(buf[13:])
	binary.LittleEndian.PutUint32(buf[9:13], h.Sum32())

	// Write to writer.
	nn, err := w.Write(buf)
	return int64(nn), err
}
269597
func (a *AsyncConfig) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, a.PacketInMask,
		a.PortStatusMask, a.FlowRemovedMask)
}
70048
func (i *InstructionWriteMetadata) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, instruction{i.Type(), 24},
		pad4{}, i.Metadata, i.MetadataMask)
}
91291
func (h HandshakeHeaderHTTP) WriteTo(w io.Writer) (int64, error) {
	wr := writer{w: w}
	err := http.Header(h).Write(&wr)
	return wr.n, err
}
1271831
func (c *Container) WriteTo(w io.Writer) (n int64, err error) {
	if c.isArray() {
		return c.arrayWriteTo(w)
	} else if c.isRun() {
		return c.runWriteTo(w)
	} else {
		return c.bitmapWriteTo(w)
	}
}
100147
func (q *QueuePropMinRate) WriteTo(w io.Writer) (int64, error) {
	header := queueProp{q.Type(), queuePropLen}
	return encoding.WriteTo(w, header, pad4{}, q.Rate, pad6{})
}
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
}
1356526
func (i Int32) WriteTo(w Writer) error {
	arr := [4]byte{byte(i), byte(i >> 8), byte(i >> 16), byte(i >> 24)}
	_, err := w.Write(arr[:])
	return errorsp.WithStacks(err)
}
560491
func WriteTo(buffers [][]*rfc5424.Message, w io.Writer) error {
	enc := gob.NewEncoder(w)
	return writeTo(buffers, enc)
}
1208646
func (f *File) WriteTo(w io.Writer) (int64, error) {
	return f.WriteToIndent(w, "")
}
435102
func (s *String) WriteTo(w io.Writer) (n int64, err error) {
	// unsigned short, can't use Short
	var length = uint16(len(s.Value))
	err = binary.Write(w, binary.BigEndian, &length)
	if err != nil {
		return
	}

	// Then write string bytes
	_, err = w.Write([]byte(s.Value))
	if err != nil {
		return
	}
	n += int64(length)

	return
}
23832
func (model *Model) WriteTo(w io.Writer) (int64, error) {
	model.RLock()
	defer model.RUnlock()
	b, err := json.Marshal(model)
	if err != nil {
		return 0, err
	}
	n, err := w.Write(b)
	if err != nil {
		return int64(n), err
	}
	return int64(n), nil
}