// Write encodes b to the underlying buffer.
963782
func (e *BooleanEncoder) Write(b bool) {
	// If we have filled the current byte, flush it
	if e.i >= 8 {
		e.flush()
	}

	// Use 1 bit for each boolean value, shift the current byte
	// by 1 and set the least signficant bit acordingly
	e.b = e.b << 1
	if b {
		e.b |= 1
	}

	// Increment the current boolean count
	e.i++
	// Increment the total boolean count
	e.n++
}
29737
func (this MBR) Write(disk io.Writer) error {
	_, err := disk.Write(this.bytes)
	return err
}
1172526
func (w *builtinWriter) Write(b []byte) (int, error) {
	return w.writeAndRetry(w.priority, string(b))
}
795796
func (d *compressor) write(b []byte) (n int, err error) {
	if d.err != nil {
		return 0, d.err
	}
	n = len(b)
	for len(b) > 0 {
		d.step(d)
		b = b[d.fill(d, b):]
		if d.err != nil {
			return 0, d.err
		}
	}
	return n, d.err
}
46843
func (c *Conversation) Write(b []byte) (int, error) {
	n := len(b)
	return n, c.Send(b2s(b))
}
223644
func (s *WriterSender) Write(p []byte) (int, error) {
	s.mu.Lock()
	defer s.mu.Unlock()
	n, err := s.writer.Write(p)
	if err != nil {
		return n, err
	}
	_ = s.writer.Flush()

	if s.buffer.Len() > 80 {
		err = s.doSend()
	}

	return n, err
}
1174932
func (r *Writer) Write(b []byte) (int, error) {
	nl := ""
	if len(b) == 0 || b[len(b)-1] != '\n' {
		nl = "\n"
	}

	r.conn.SetWriteDeadline(time.Now().Add(1 * time.Second))

	_, err := fmt.Fprintf(r.conn, "  %s  %s%s", syslogHeader, b, nl)
	if err != nil {
		return 0, err
	}

	return len(b), nil
}
526167
func (c *Conn) Write(b []byte) (n int, err error) {
	return c.Writer.Write(b)
}
729434
func (s *Stream) Write(b []byte) (n int, err error) {
	s.sendLock.Lock()
	defer s.sendLock.Unlock()
	total := 0
	for total < len(b) {
		n, err := s.write(b[total:])
		total += n
		if err != nil {
			return total, err
		}
	}
	return total, nil
}
84776
func (xw *Writer) Write(buf []byte) (int, error) {
	if xw.err != nil {
		return 0, xw.err
	}

	var n, cnt int
	for len(buf) > 0 && xw.err == nil {
		// Flush chunk if necessary.
		remain := xw.nchk - xw.zw.InputOffset
		if remain <= 0 {
			xw.err = xw.Flush(FlushFull)
			continue
		}
		if remain > int64(len(buf)) {
			remain = int64(len(buf))
		}

		// Compress data for current chunk.
		offset := xw.zw.OutputOffset
		n, xw.err = xw.zw.Write(buf[:remain])
		xw.OutputOffset += xw.zw.OutputOffset - offset
		buf = buf[n:]
		cnt += n
	}

	xw.InputOffset += int64(cnt)
	return cnt, xw.err
}
622272
func (v *Buf) Write(p []byte) (int, error) {
	l := len(p)
	writeEnd := int(v.ptr) + l - len(*v.buf)
	if writeEnd > 0 {
		err := v.grow(writeEnd)
		if err != nil {
			return 0, err
		}
	}
	copy((*v.buf)[v.ptr:], p)
	v.ptr += int64(l)
	return l, nil
}
854668
func (w *CountWriter) Write(b []byte) (n int, err error) {
	if n, err = w.W.Write(b); n > 0 {
		w.N += n
	}
	return
}
378683
func (w *Writer) Write(p []byte) (int, error) {
	c, l, ln := cap(w.buf), len(w.buf), len(p)
	avail := c - l

	// requires flush
	if avail < ln {
		if err := w.Flush(); err != nil {
			return 0, err
		}
		l = len(w.buf)
	}
	// too big to fit in buffer;
	// write directly to w.w
	if c < ln {
		return w.w.Write(p)
	}

	// grow buf slice; copy; return
	w.buf = w.buf[:l+ln]
	return copy(w.buf[l:], p), nil
}
585771
func (s *serialWriteCloser) Write(data []byte) (int, error) {
	s.mu.Lock()
	defer s.mu.Unlock()
	return s.wc.Write(data)
}
376631
func (bw *BufferedFileWriter) Write(p []byte) (int, error) {
	bw.mu.Lock()
	n, err := bw.bufWriter.Write(p)

	// Special Case... if the used space in the buffer is LESS than
	// the input, then we did a flush in the middle of the line
	// and the full log line was not sent on its way.
	if bw.bufWriter.Buffered() < len(p) {
		bw.bufWriter.Flush()
	}

	bw.mu.Unlock()
	return n, err
}
683312
func (w *Writer) Write(buf []byte) (int, error) {
	if len(buf) > 0 {
		if w.start == -1 {
			// Find start of message index
			for i, c := range buf {
				if c == Delimiter && i > 0 {
					l := buf[i-1]
					level := Levels[l]
					if level > 0 {
						w.start = i - 1
						break
					}
				}
			}
			if w.start == -1 {
				buf = append(invalidMSG, buf...)
				return w.w.Write(buf)
			}
		}
		l := Levels[buf[w.start]]
		if l >= LogLevel() {
			return w.w.Write(buf)
		} else if l == 0 {
			buf = append(invalidMSG, buf...)
			return w.w.Write(buf)
		}
	}
	return 0, nil
}
667733
func (w *Writer) Write(b []byte) (int, error) {
	if w.closed {
		return 0, io.ErrClosedPipe
	}

	if w.err != nil {
		return 0, w.err
	}

	return w.buffer(b)
}