// Encode serializes the target AcceptChannel into the passed io.Writer
// implementation. Serialization will observe the rules defined by the passed
// protocol version.
//
// This is part of the lnwire.Message interface.
330422
func (a *AcceptChannel) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w,
		a.PendingChannelID[:],
		a.DustLimit,
		a.MaxValueInFlight,
		a.ChannelReserve,
		a.HtlcMinimum,
		a.MinAcceptDepth,
		a.CsvDelay,
		a.MaxAcceptedHTLCs,
		a.FundingKey,
		a.RevocationPoint,
		a.PaymentPoint,
		a.DelayedPaymentPoint,
		a.HtlcPoint,
		a.FirstCommitmentPoint,
	)
}
1157808
func (e *Encoder) Encode(v interface{}) error {
	val := reflect.ValueOf(v)
	return e.encode(val)
}
1009454
func encode(i interface{}, w http.ResponseWriter) {
	w.Header().Add("Content-Type", "application/json")

	enc := json.NewEncoder(w)
	err := enc.Encode(i)
	// Problems encoding
	if err != nil {
		LoggingClient.Error("Error encoding the data: " + err.Error())
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
}
69744
func Encode(charset int, utf_8 []byte) (latin []byte, success int, err error) {
	return converters[charset].Encode(utf_8)
}
1333769
func Encode(in []byte) (string, error) {
	return b64.StdEncoding.EncodeToString(in), nil
}
157733
func Encode(w io.Writer, feed *Feed) error {
	enc := xml.NewEncoder(w)
	if _, err := w.Write([]byte(xml.Header)); err != nil {
		return err
	}
	return enc.Encode(feed)
}
354401
func (f *FailInvalidOnionHmac) Encode(w io.Writer, pver uint32) error {
	return WriteElement(w, f.OnionSHA256[:])
}
691567
func (h *htlcSuccessResolver) Encode(w io.Writer) error {
	// First we'll encode our inner HTLC resolution.
	if err := encodeIncomingResolution(w, &h.htlcResolution); err != nil {
		return err
	}

	// Next, we'll write out the fields that are specified to the contract
	// resolver.
	if err := binary.Write(w, endian, h.outputIncubating); err != nil {
		return err
	}
	if err := binary.Write(w, endian, h.resolved); err != nil {
		return err
	}
	if err := binary.Write(w, endian, h.broadcastHeight); err != nil {
		return err
	}
	if _, err := w.Write(h.payHash[:]); err != nil {
		return err
	}

	return nil
}
969453
func (e StringEncoder) Encode(data interface{}, out *goetty.ByteBuf) error {
	msg, _ := data.(string)
	bytes := []byte(msg)
	out.WriteInt(len(bytes))
	out.Write(bytes)
	return nil
}
711322
func (v BoolValue) encode(w io.Writer) error {
	return binary.Write(w, binary.BigEndian, v.valueType())
}
881528
func Encode(v interface{}) ([]byte, error) {
	var buf bytes.Buffer
	zw := zlib.NewWriter(&buf)
	enc := json.NewEncoder(zw)

	if err := enc.Encode(v); err != nil {
		zw.Close()
		return nil, errors.Annotate(err, "failed to JSON-encode").Err()
	}
	if err := zw.Close(); err != nil {
		return nil, errors.Annotate(err, "failed to Close zlib Writer").Err()
	}
	return buf.Bytes(), nil
}
753835
func Encode(value string) string {
	encoded := make([]byte, base64.URLEncoding.EncodedLen(len(value)))
	base64.URLEncoding.Encode(encoded, []byte(value))
	return string(encoded)
}
328542
func (encoder *IntLengthFieldBasedEncoder) Encode(data interface{}, out *ByteBuf) error {
	buf := NewByteBuf(32)

	if encoder.prepare != nil {
		err := encoder.prepare(data, out)
		if err != nil {
			return err
		}
	}

	err := encoder.base.Encode(data, buf)
	if err != nil {
		return err
	}

	out.WriteInt(buf.Readable())
	out.WriteByteBuf(buf)
	return nil
}
730372
func Encode(in []byte) string {
	out := Client().Encode(in)
	Trace("Encode", nil, logrus.Fields{"in": in, "out": out})
	return out
}
183531
func (msg *Init) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w,
		msg.ConnFeatures,
		msg.ChainHash,
	)
}
814349
func (ctx *Context) Encode(v interface{}) (string, error) {
	accept := ctx.Request.Header.Peek(acceptHeader)
	accepted := acceptParser.Parse(BytesToString(accept))

	sentType, err := accepted.Negotiate(ctypes...)
	if err != nil {
		return emptyString, err
	}

	switch sentType {
	case jsonCT:
		err = ctx.JSON(v)
	case xmlCT:
		err = ctx.XML(v)
	case csvCT:
		err = ctx.CSV(v)
	}

	return sentType, err
}
788627
func (v StringValue) encode(w io.Writer) error {
	raw := rawValue{
		Type: v.valueType(),
	}

	return raw.encodeString(w, string(v))
}