// Encode the Component into the ical format
327906
func (enc *ICalEncode) Encode(c ICalEmiter) {
	component := c.EmitICal()
	component.Write(enc)
}
52389
func (e Encoder) encode(iVal interface{}) error {

	var err error
	switch val := iVal.(type) {
	case nil:
		err = e.encodeNil()
	case bool:
		err = e.encodeBool(val)
	case int:
		err = e.encodeInt(int64(val))
	case int8:
		err = e.encodeInt(int64(val))
	case int16:
		err = e.encodeInt(int64(val))
	case int32:
		err = e.encodeInt(int64(val))
	case int64:
		err = e.encodeInt(val)
	case uint:
		err = e.encodeInt(int64(val))
	case uint8:
		err = e.encodeInt(int64(val))
	case uint16:
		err = e.encodeInt(int64(val))
	case uint32:
		err = e.encodeInt(int64(val))
	case uint64:
		if val > math.MaxInt64 {
			return errors.New("Integer too big: %d. Max integer supported: %d", val, int64(math.MaxInt64))
		}
		err = e.encodeInt(int64(val))
	case float32:
		err = e.encodeFloat(float64(val))
	case float64:
		err = e.encodeFloat(val)
	case string:
		err = e.encodeString(val)
	case []interface{}:
		err = e.encodeSlice(val)
	case map[string]interface{}:
		err = e.encodeMap(val)
	case structures.Structure:
		err = e.encodeStructure(val)
	default:
		// arbitrary slice types
		if reflect.TypeOf(iVal).Kind() == reflect.Slice {
			s := reflect.ValueOf(iVal)
			newSlice := make([]interface{}, s.Len())
			for i := 0; i < s.Len(); i++ {
				newSlice[i] = s.Index(i).Interface()
			}
			return e.encodeSlice(newSlice)
		}

		return errors.New("Unrecognized type when encoding data for Bolt transport: %T %+v", val, val)
	}

	return err
}
756930
func (s *SessionInfo) Encode(w io.Writer) error {
	return WriteElements(w,
		s.ID,
		s.Policy,
		s.LastApplied,
		s.ClientLastApplied,
		s.RewardAddress,
	)
}
917057
func (u *SessionStateUpdate) Encode(w io.Writer) error {
	return WriteElements(w,
		u.ID,
		u.SeqNum,
		u.LastApplied,
		u.Hint,
		u.EncryptedBlob,
	)
}
958335
func Encode(element interface{}) (map[string]string, error) {
	node, err := internal.EncodeToNode(element)
	if err != nil {
		return nil, err
	}

	return internal.EncodeNode(node), nil
}
1254007
func (c *UpdateFailHTLC) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w,
		c.ChanID,
		c.ID,
		c.Reason,
	)
}
572094
func (f *FundingSigned) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w, f.ChanID, f.CommitSig)
}
660413
func Encode(structPtr interface{}) (bytes []byte, err error) {
	defer func() {
		if e := recover(); e != nil {
			err = errors.New(e.(string))
			bytes = nil
		}
	}()
	if structPtr == nil {
		return nil, nil
	}

	if bu, ok := structPtr.(encoding.BinaryMarshaler); ok {
		return bu.MarshalBinary()
	}

	en := encoder{}
	val := reflect.ValueOf(structPtr)
	if val.Kind() != reflect.Ptr {
		return nil, errors.New("encode takes a pointer to struct")
	}
	en.message(val.Elem())
	return en.Bytes(), nil
}
691177
func (c *Error) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w,
		c.ChanID,
		c.Data,
	)
}
997579
func EncodeToNode(element interface{}) (*Node, error) {
	rValue := reflect.ValueOf(element)
	node := &Node{Name: "traefik"}

	err := setNodeValue(node, rValue)
	if err != nil {
		return nil, err
	}

	return node, nil
}
832490
func encodeJavascript(buf *bytes.Buffer, name string, val Javascript) error {
	// type
	if err := buf.WriteByte(_JAVASCRIPT); err != nil {
		return err
	}

	// name
	if err := writeCstring(buf, name); err != nil {
		return err
	}

	// value
	return writeString(buf, string(val))
}
295302
func (sc ServiceCheck) Encode(tags ...string) (string, error) {
	err := sc.Check()
	if err != nil {
		return "", err
	}
	message := sc.escapedMessage()

	var buffer bytes.Buffer
	buffer.WriteString("_sc|")
	buffer.WriteString(sc.Name)
	buffer.WriteRune('|')
	buffer.WriteString(strconv.FormatInt(int64(sc.Status), 10))

	if !sc.Timestamp.IsZero() {
		buffer.WriteString("|d:")
		buffer.WriteString(strconv.FormatInt(int64(sc.Timestamp.Unix()), 10))
	}

	if len(sc.Hostname) != 0 {
		buffer.WriteString("|h:")
		buffer.WriteString(sc.Hostname)
	}

	writeTagString(&buffer, tags, sc.Tags)

	if len(message) != 0 {
		buffer.WriteString("|m:")
		buffer.WriteString(message)
	}

	return buffer.String(), nil
}
1233363
func (l *LogUpdate) Encode(w io.Writer) error {
	return WriteElements(w, l.LogIndex, l.UpdateMsg)
}
1076131
func (cse *SessionCookieEngine) Encode(c *Controller) {

	c.SetCookie(cse.GetCookie(c.Session))
}
962970
func (cp *Connack) Encode(dst []byte) (int, error) {
	total := 0

	// encode header
	n, err := headerEncode(dst[total:], 0, 2, cp.Len(), CONNACK)
	total += n
	if err != nil {
		return total, err
	}

	// set session present flag
	if cp.SessionPresent {
		dst[total] = 1 // 00000001
	} else {
		dst[total] = 0 // 00000000
	}
	total++

	// check return code
	if !cp.ReturnCode.Valid() {
		return total, makeError(cp.Type(), "invalid return code (%d)", cp.ReturnCode)
	}

	// set return code
	dst[total] = byte(cp.ReturnCode)
	total++

	return total, nil
}
583620
func (c *RevokeAndAck) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w,
		c.ChanID,
		c.Revocation[:],
		c.NextRevocationKey,
	)
}
1067673
func (c *UpdateFailMalformedHTLC) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w,
		c.ChanID,
		c.ID,
		c.ShaOnionBlob[:],
		c.FailureCode,
	)
}