// Encode serializes the target CreateSession into the passed io.Writer
// observing the protocol version specified.
//
// This is part of the wtwire.Message interface.
761457
func (m *CreateSession) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w,
		m.BlobType,
		m.MaxUpdates,
		m.RewardBase,
		m.RewardRate,
		m.SweepFeeRate,
	)
}
476301
func (m *Marshaller) Encode(obj interface{}, w io.Writer) error {
	m.writer.w = w
	err := m.marshal.Marshal(obj)
	m.writer.w = nil
	return err
}
280326
func (rs *ReplaySet) Encode(w io.Writer) error {
	for seqNum := range rs.replays {
		err := binary.Write(w, binary.BigEndian, seqNum)
		if err != nil {
			return err
		}
	}

	return nil
}
1076131
func (cse *SessionCookieEngine) Encode(c *Controller) {

	c.SetCookie(cse.GetCookie(c.Session))
}
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
}
759788
func Encode(w io.Writer, m image.Image, opt *Options) (err error) {
	return encode(w, m, opt)
}
1315699
func EncodeHTTPCreateSessionResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {
	res := response.(createSessionResponse)
	if res.Err != nil {
		return businessErrorEncoder(ctx, res.Err, w)
	}
	defer kitty.TraceStatusAndFinish(ctx, w.Header(), 201)
	encodeSession(w, res.Session, 201)
	return nil
}
293685
func (req *SnapshotRecoveryRequest) Encode(w io.Writer) (int, error) {

	protoPeers := make([]*protobuf.SnapshotRecoveryRequest_Peer, len(req.Peers))

	for i, peer := range req.Peers {
		protoPeers[i] = &protobuf.SnapshotRecoveryRequest_Peer{
			Name:             proto.String(peer.Name),
			ConnectionString: proto.String(peer.ConnectionString),
		}
	}

	pb := &protobuf.SnapshotRecoveryRequest{
		LeaderName: proto.String(req.LeaderName),
		LastIndex:  proto.Uint64(req.LastIndex),
		LastTerm:   proto.Uint64(req.LastTerm),
		Peers:      protoPeers,
		State:      req.State,
	}
	p, err := proto.Marshal(pb)
	if err != nil {
		return -1, err
	}

	return w.Write(p)
}
1233363
func (l *LogUpdate) Encode(w io.Writer) error {
	return WriteElements(w, l.LogIndex, l.UpdateMsg)
}
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)
}
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)
}
882496
func (c *ClosingSigned) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w, c.ChannelID, c.FeeSatoshis, c.Signature)
}
691177
func (c *Error) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w,
		c.ChanID,
		c.Data,
	)
}
756930
func (s *SessionInfo) Encode(w io.Writer) error {
	return WriteElements(w,
		s.ID,
		s.Policy,
		s.LastApplied,
		s.ClientLastApplied,
		s.RewardAddress,
	)
}
682672
func (m *StateUpdate) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w,
		m.SeqNum,
		m.LastApplied,
		m.IsComplete,
		m.Hint,
		m.EncryptedBlob,
	)
}
1224457
func (enc *encoder) Encode(vs ...interface{}) (err error) {
	defer func() {
		err, _ = recover().(error)
	}()
	for _, v := range vs {
		enc.encode(reflect.ValueOf(v), 0)
	}
	return nil
}
1322505
func Encode(v interface{}) []byte {
	encoder := encoder{}
	encoder.writeInterfaceType(v)
	return encoder.Bytes()
}