// EncodeTo writes an ASAR archive containing Entry's descendants. This function
// is usally called on the root entry.
966793
func (e *Entry) EncodeTo(w io.Writer) (n int64, err error) {

	defer func() {
		if r := recover(); r != nil {
			if e := r.(error); e != nil {
				err = e
			} else {
				panic(r)
			}
		}

	}()

	encoder := entryEncoder{}
	{
		var reserve [16]byte
		encoder.Header.Write(reserve[:])
	}
	encoder.Encoder = json.NewEncoder(&encoder.Header)
	if err = encoder.Encode(e); err != nil {
		return
	}

	{
		var padding [3]byte
		encoder.Header.Write(padding[:encoder.Header.Len()%4])
	}

	header := encoder.Header.Bytes()
	binary.LittleEndian.PutUint32(header[:4], 4)
	binary.LittleEndian.PutUint32(header[4:8], 8+uint32(encoder.Header.Len()))
	binary.LittleEndian.PutUint32(header[8:12], 4+uint32(encoder.Header.Len()))
	binary.LittleEndian.PutUint32(header[12:16], uint32(encoder.Header.Len()))

	n, err = encoder.Header.WriteTo(w)
	if err != nil {
		return
	}

	for _, chunk := range encoder.Contents {
		var written int64
		written, err = io.Copy(w, chunk)
		n += written
		if err != nil {
			return
		}
	}

	return
}
247957
func (e *Encoder) Encode(src interface{}, dst map[string][]string) error {
	v := reflect.ValueOf(src)

	return e.encode(v, dst)
}
581141
func encode(src interface{}) ([]byte, error) {
	jsoninsh, err := json.Marshal(src)
	if err != nil {
		return nil, err
	}

	var buf bytes.Buffer
	gsw := gzip.NewWriter(&buf)
	_, err = gsw.Write(jsoninsh)
	if err != nil {
		return nil, err
	}
	err = gsw.Close()
	if err != nil {
		return nil, err
	}
	return buf.Bytes(), nil
}
657431
func (eui *DevEUI) MarshalTo(b []byte) (int, error) {
	copy(b, eui.Bytes())
	return 8, nil
}
1045788
func (resp *AppendEntriesResponse) Encode(w io.Writer) (int, error) {
	b, err := proto.Marshal(resp.pb)
	if err != nil {
		return -1, err
	}

	return w.Write(b)
}
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
}
1371525
func (enc *Encoder) Encode(root *Node) error {
	if enc.err != nil {
		return enc.err
	}
	if root == nil {
		return nil
	}

	enc.err = enc.format(root, 0)

	// Terminate each value with a newline.
	// This makes the output look a little nicer
	// when debugging, and some kind of space
	// is required if the encoded value was a number,
	// so that the reader knows there aren't more
	// digits coming.
	enc.write("\n")

	return enc.err
}
289642
func (f *decompressor) WriteTo(w io.Writer) (int64, error) {
	total := int64(0)
	flushed := false
	for {
		if len(f.toRead) > 0 {
			n, err := w.Write(f.toRead)
			total += int64(n)
			if err != nil {
				f.err = err
				return total, err
			}
			if n != len(f.toRead) {
				return total, io.ErrShortWrite
			}
			f.toRead = f.toRead[:0]
		}
		if f.err != nil && flushed {
			if f.err == io.EOF {
				return total, nil
			}
			return total, f.err
		}
		if f.err == nil {
			f.step(f)
		}
		if len(f.toRead) == 0 && f.err != nil && !flushed {
			f.toRead = f.dict.readFlush() // Flush what's left in case of error
			flushed = true
		}
	}
}
874577
func (e *Encoding) EncodeToString(src []byte) string {
	dst := make([]byte, EncodedLen(len(src)))
	e.Encode(dst, src)
	return string(dst)
}
810996
func (f *FailExpiryTooSoon) Encode(w io.Writer, pver uint32) error {
	return writeOnionErrorChanUpdate(w, &f.Update, pver)
}
1368768
func (us *UnSme) SerializeTo(w io.Writer) error {
	_, err := w.Write(us.Bytes())
	return err
}
470927
func (f *FormatEncoder) EncodeEntry(entry zapcore.Entry, fields []zapcore.Field) (*buffer.Buffer, error) {
	line := f.pool.Get()
	for _, f := range f.formatters {
		f.Format(line, entry, fields)
	}

	encodedFields, err := f.Encoder.EncodeEntry(entry, fields)
	if err != nil {
		return nil, err
	}
	if line.Len() > 0 && encodedFields.Len() != 1 {
		line.AppendString(" ")
	}
	line.AppendString(encodedFields.String())
	encodedFields.Free()

	return line, nil
}
1184050
func (c *cState) encodeZero(symbolTT symbolTransform) {
	nbBitsOut := (uint32(c.state) + symbolTT.deltaNbBits) >> 16
	dstState := int32(c.state>>(nbBitsOut&15)) + symbolTT.deltaFindState
	c.bw.addBits16ZeroNC(c.state, uint8(nbBitsOut))
	c.state = c.stateTable[dstState]
}
370438
func (r *Encoder) EncodeNone() error {
	_, err := r.w.Write([]byte{CHR_NONE})
	return err
}
1235080
func (r Raw) MarshalTo(data []byte) (n int, err error) {
	if len(r) == 0 {
		return 0, nil
	}
	copy(data, r)
	return len(r), nil
}
269597
func (a *AsyncConfig) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, a.PacketInMask,
		a.PortStatusMask, a.FlowRemovedMask)
}
818115
func (e *Exportable) WriteTo(w io.Writer) (int64, error) {
	return e.buffer.WriteTo(w)
}