// NewAuthHeaderWriterTo returns an io.WriterTo that can write an
// authentication header with the given parameters to a Writer.
511216
func NewAuthHeaderWriterTo(token, payload []byte, signer Signer) io.WriterTo {
	return &authHeaderWriterTo{token, payload, signer}
}
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
}
1280358
func (b *Builder) WriteTo(w Writer) error {
	switch b.optype {
	case condType:
		return b.cond.WriteTo(w)
	case selectType:
		return b.selectWriteTo(w)
	case insertType:
		return b.insertWriteTo(w)
	case updateType:
		return b.updateWriteTo(w)
	case deleteType:
		return b.deleteWriteTo(w)
	}

	return ErrNotSupportType
}
483879
func (tw *Writer) WriteHeader(hdr *Header) error {
	return tw.writeHeader(hdr, true)
}
977574
func NewWriter(w io.Writer, h *Header, flags int) (*Writer, error) {
	if flags < FlagDecimal || flags > FlagString {
		return nil, errors.New("bam: flag format option out of range")
	}
	sw := &Writer{w: w, flags: flags}
	text, _ := h.MarshalText()
	_, err := w.Write(text)
	if err != nil {
		return nil, err
	}
	return sw, nil
}
334698
func (s *RequestHeaderAuthenticationOptions) ToAuthenticationRequestHeaderConfig() *authenticatorfactory.RequestHeaderConfig {
	if len(s.ClientCAFile) == 0 {
		return nil
	}

	return &authenticatorfactory.RequestHeaderConfig{
		UsernameHeaders:     s.UsernameHeaders,
		GroupHeaders:        s.GroupHeaders,
		ExtraHeaderPrefixes: s.ExtraHeaderPrefixes,
		ClientCA:            s.ClientCAFile,
		AllowedClientNames:  s.AllowedNames,
	}
}
618244
func (writer *Writer) WriteHeader() error {
	if !writer.Resource.Config.WithoutHeader {
		writer.currentRow++
		for key, meta := range writer.metas {
			writer.Writer.SetCellValue(writer.sheetName, toAxis(key, writer.currentRow), meta.Header)
		}
	}
	return nil
}
1195648
func (w *http2responseWriter) WriteHeader(code int) {
	if atomic.CompareAndSwapInt32(w.code, 0, int32(code)) {
		w.ResponseWriter.WriteHeader(code)
	}
}
269597
func (a *AsyncConfig) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, a.PacketInMask,
		a.PortStatusMask, a.FlowRemovedMask)
}
721233
func (h *Header) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, *h)
}
873575
func (f HandshakeHeaderFunc) WriteTo(w io.Writer) (int64, error) {
	return f(w)
}
824310
func noAuthHeaders(c context.Context, uri string, opts *rpcOptions) (*oauth2.Token, map[string]string, error) {
	return nil, nil, nil
}
293658
func (ih *InnerHeader) writeTo(w io.Writer) error {
	irsID := make([]byte, 4)
	binary.LittleEndian.PutUint32(irsID, ih.InnerRandomStreamID)

	if err := writeToInnerHeader(w, InnerHeaderIRSID, irsID); err != nil {
		return err
	}
	if err := writeToInnerHeader(w, InnerHeaderIRSKey, ih.InnerRandomStreamKey); err != nil {
		return err
	}

	for _, item := range ih.Binaries {
		buf := []byte{item.MemoryProtection}
		buf = append(buf, item.Content...)
		if err := writeToInnerHeader(w, InnerHeaderBinary, buf); err != nil {
			return err
		}
	}
	// End inner header
	if err := binary.Write(w, binary.LittleEndian, InnerHeaderTerminator); err != nil {
		return err
	}
	return binary.Write(w, binary.LittleEndian, uint32(0))
}
476921
func (fh FileHeaders) writeTo31(w io.Writer) error {
	compressionFlags := make([]byte, 4)
	binary.LittleEndian.PutUint32(compressionFlags, fh.CompressionFlags)

	transformRounds := make([]byte, 8)
	binary.LittleEndian.PutUint64(transformRounds, fh.TransformRounds)

	innerRandomStreamID := make([]byte, 4)
	binary.LittleEndian.PutUint32(innerRandomStreamID, fh.InnerRandomStreamID)

	if err := writeTo31Header(w, 1, fh.Comment); err != nil {
		return err
	}
	if err := writeTo31Header(w, 2, fh.CipherID); err != nil {
		return err
	}
	if err := writeTo31Header(w, 3, compressionFlags); err != nil {
		return err
	}
	if err := writeTo31Header(w, 4, fh.MasterSeed); err != nil {
		return err
	}
	if err := writeTo31Header(w, 5, fh.TransformSeed); err != nil {
		return err
	}
	if err := writeTo31Header(w, 6, transformRounds); err != nil {
		return err
	}
	if err := writeTo31Header(w, 7, fh.EncryptionIV); err != nil {
		return err
	}
	if err := writeTo31Header(w, 8, fh.ProtectedStreamKey); err != nil {
		return err
	}
	if err := writeTo31Header(w, 9, fh.StreamStartBytes); err != nil {
		return err
	}
	if err := writeTo31Header(w, 10, innerRandomStreamID); err != nil {
		return err
	}
	// End of header
	return writeTo31Header(w, 0, []byte{0x0D, 0x0A, 0x0D, 0x0A})
}
674039
func (m *MeterConfigRequest) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, m.Meter, pad4{})
}
1143229
func (r *RPCHeaderHandler) WriteHeader(w io.Writer, req []byte, writeAuth bool) error {
	var (
		token string
		err   error
		err2  error
	)
	binary.Write(w, byteOrder, RPCMagicNumber)
	if writeAuth {
		binary.Write(w, byteOrder, uint8(1))
		// get current host token
		var signer Signer = &delegateKeys
		token, err = AuthTokenNonBlocking()
		if err != nil {
			log.WithError(err).Debug("Unable to retrieve delegate token")
			// We may be an un-added master
			token, err2 = MasterToken()
			if err2 != nil {
				log.WithError(err2).Debug("Unable to retrieve master token")
				// Return the original error message
				return err
			}
			signer = &masterKeys
		}
		h := NewAuthHeaderWriterTo([]byte(token), req, signer)
		_, err = h.WriteTo(w)
	} else {
		binary.Write(w, byteOrder, uint8(0))
		WriteLengthAndBytes(req, w)
	}
	return err
}
240957
func (p *SSHPath) WriteTo(out io.Writer) (int64, error) {
	sftpClient, err := p.newClient()
	if err != nil {
		return 0, err
	}
	defer sftpClient.Close()

	f, err := sftpClient.Open(p.path)
	if err != nil {
		return 0, fmt.Errorf("error opening file %s over sftp: %v", p, err)
	}
	defer f.Close()

	return f.WriteTo(out)
}