// Encode writes the provided object to the nested writer.
962452
func (e *encoder) Encode(obj runtime.Object) error {
	if err := e.encoder.Encode(obj, e.buf); err != nil {
		return err
	}
	_, err := e.writer.Write(e.buf.Bytes())
	e.buf.Reset()
	return err
}
583620
func (c *RevokeAndAck) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w,
		c.ChanID,
		c.Revocation[:],
		c.NextRevocationKey,
	)
}
709605
func (a *AddRef) Encode(w io.Writer) error {
	if err := binary.Write(w, binary.BigEndian, a.Height); err != nil {
		return err
	}

	return binary.Write(w, binary.BigEndian, a.Index)
}
1206269
func Encode(ctx context.Context) ([]byte, error) {
	m := ToMap(ctx)
	if len(m) > 0 {
		return json.Marshal(m)
	}
	return nil, nil
}
495507
func (codec *StringCodec) Encode(data interface{}, out *ByteBuf) error {
	if msg, ok := data.(string); ok {
		return out.WriteString(msg)
	}

	return fmt.Errorf("not string: %+v", data)
}
140510
func (c *CodecMsgpack) Encode(obj interface{}) (buf []byte, err error) {
	err = codec.NewEncoderBytes(&buf, c.h).Encode(obj)
	if err != nil {
		return nil, errors.Wrap(err, "failed to encode")
	}
	return buf, nil
}
1205387
func (w *Stream) Encode(m JSONMessage) error {
	return w.enc.Encode(m)
}
1046887
func Encode(w io.Writer, v interface{}, order binary.ByteOrder) (int, error) {
	b, err := json.Marshal(v)
	if err != nil {
		return 0, err
	}
	return Write(w, bytes.NewReader(b), order)
}
360218
func (b *Blob) Encode(o plumbing.EncodedObject) (err error) {
	o.SetType(plumbing.BlobObject)

	w, err := o.Writer()
	if err != nil {
		return err
	}

	defer ioutil.CheckClose(w, &err)

	r, err := b.Reader()
	if err != nil {
		return err
	}

	defer ioutil.CheckClose(r, &err)

	_, err = io.Copy(w, r)
	return err
}
693631
func (cu *CellUnion) Encode(w io.Writer) error {
	e := &encoder{w: w}
	cu.encode(e)
	return e.err
}
928499
func (enc *Encoder) Encode(m *Message) (err error) {

	_, err = enc.Write(m.Bytes())

	return
}
867066
func (c *FundingLocked) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w,
		c.ChanID,
		c.NextPerCommitmentPoint)
}
202270
func (s *SphinxErrorEncrypter) Encode(w io.Writer) error {
	ephemeral := s.EphemeralKey.SerializeCompressed()
	_, err := w.Write(ephemeral)
	return err
}
187345
func (adapter *Encoder) Encode(val interface{}) error {
	adapter.stream.WriteVal(val)
	adapter.stream.WriteRaw("\n")
	adapter.stream.Flush()
	return adapter.stream.Error
}
134538
func (enc *Encoder) Encode(w io.Writer, nim image.Image, params imageserver.Params) error {
	return gif.Encode(w, nim, nil)
}
579839
func (params Params) Encode(writer io.Writer) (mime string, err error) {
	if params == nil || len(params) == 0 {
		mime = _MIME_FORM_URLENCODED
		return
	}

	// check whether params contains any binary data.
	hasBinary := false

	for _, v := range params {
		typ := reflect.TypeOf(v)

		if typ == typeOfPointerToBinaryData || typ == typeOfPointerToBinaryFile {
			hasBinary = true
			break
		}
	}

	if hasBinary {
		return params.encodeMultipartForm(writer)
	}

	return params.encodeFormUrlEncoded(writer)
}
1102564
func (jsonEncoder) Encode(v ...interface{}) string {
	var data interface{} = v
	if v == nil {
		// So that empty results produces `[]` and not `null`
		data = []interface{}{}
	} else if len(v) == 1 {
		data = v[0]
	}
	b, err := json.Marshal(data)
	if err != nil {
		panic(err)
	}
	log.Printf("%s", b)
	return string(b)
}