// encode encodes the Int16Value into an eventstream binary value
// representation.
420478
func (v Int16Value) encode(w io.Writer) error {
	raw := rawValue{
		Type: v.valueType(),
	}
	return raw.encodeScalar(w, v)
}
1012221
func (ae *AttributeEncoder) Encode() ([]byte, error) {
	if ae.err != nil {
		return nil, ae.err
	}

	return MarshalAttributes(ae.attrs)
}
505536
func encode(b []byte) []byte {
	var buf bytes.Buffer
	mw := meta.NewWriter(&buf)
	mw.FinalMode = meta.FinalMeta
	if _, err := io.Copy(mw, bytes.NewReader(b)); err != nil {
		log.Fatal(err)
	}
	if err := mw.Close(); err != nil {
		log.Fatal(err)
	}
	return buf.Bytes()
}
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
}
704055
func (e *Encoder) Encode(v interface{}) error {
	f, ok := v.(marshalerFaster)
	if ok {
		e.buf.Reset()
		err := f.MarshalJSONBuf(&e.buf)
		if err != nil {
			return err
		}

		_, err = io.Copy(e.w, &e.buf)
		return err
	}

	return e.enc.Encode(v)
}
138771
func Encode(b []byte, v int64) int {
	u := uint64(v)
	switch {
	case u < 0x80:
		b[0] = byte(u)
		return 1
	case u < 0x4000:
		_ = b[1]
		b[0] = byte(u>>8)&0x3f | 0x80
		b[1] = byte(u)
		return 2
	case u < 0x200000:
		_ = b[2]
		b[0] = byte(u>>16)&0x1f | 0xc0
		b[1] = byte(u >> 8)
		b[2] = byte(u)
		return 3
	case u < 0x10000000:
		_ = b[3]
		b[0] = byte(u>>24)&0x0f | 0xe0
		b[1] = byte(u >> 16)
		b[2] = byte(u >> 8)
		b[3] = byte(u)
		return 4
	case u < 0x800000000:
		_ = b[4]
		b[0] = byte(u>>32)&0x07 | 0xf0
		b[1] = byte(u >> 24)
		b[2] = byte(u >> 16)
		b[3] = byte(u >> 8)
		b[4] = byte(u)
		return 5
	case u < 0x40000000000:
		_ = b[5]
		b[0] = byte(u>>40)&0x03 | 0xf8
		b[1] = byte(u >> 32)
		b[2] = byte(u >> 24)
		b[3] = byte(u >> 16)
		b[4] = byte(u >> 8)
		b[5] = byte(u)
		return 6
	case u < 0x2000000000000:
		_ = b[6]
		b[0] = byte(u>>48)&0x01 | 0xfc
		b[1] = byte(u >> 40)
		b[2] = byte(u >> 32)
		b[3] = byte(u >> 24)
		b[4] = byte(u >> 16)
		b[5] = byte(u >> 8)
		b[6] = byte(u)
		return 7
	case u < 0x100000000000000:
		_ = b[7]
		b[0] = 0xfe
		b[1] = byte(u >> 48)
		b[2] = byte(u >> 40)
		b[3] = byte(u >> 32)
		b[4] = byte(u >> 24)
		b[5] = byte(u >> 16)
		b[6] = byte(u >> 8)
		b[7] = byte(u)
		return 8
	default:
		_ = b[8]
		b[0] = 0xff
		b[1] = byte(u >> 56)
		b[2] = byte(u >> 48)
		b[3] = byte(u >> 40)
		b[4] = byte(u >> 32)
		b[5] = byte(u >> 24)
		b[6] = byte(u >> 16)
		b[7] = byte(u >> 8)
		b[8] = byte(u)
		return 9
	}
}
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
}
847035
func (e *Encoder) Encode(fields map[string]interface{}, fPort uint8) ([]byte, bool, error) {
	encoder := protocol.NewEncoder()
	for name, value := range fields {
		key, channel, err := parseName(name)
		if err != nil {
			continue
		}
		switch key {
		case valueKey:
			if val, ok := value.(float64); ok {
				encoder.AddPort(channel, float32(val))
			}
		}
	}
	return encoder.Bytes(), true, nil
}
429794
func (enc *Encoder) Encode(v interface{}) error {
	if enc.err != nil {
		return enc.err
	}
	e := newEncodeState()
	err := e.marshal(v, encOpts{escapeHTML: enc.escapeHTML})
	if err != nil {
		return err
	}

	// 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.
	e.WriteByte('\n')

	b := e.Bytes()
	if enc.indentPrefix != "" || enc.indentValue != "" {
		if enc.indentBuf == nil {
			enc.indentBuf = new(bytes.Buffer)
		}
		enc.indentBuf.Reset()
		err = Indent(enc.indentBuf, b, enc.indentPrefix, enc.indentValue)
		if err != nil {
			return err
		}
		b = enc.indentBuf.Bytes()
	}
	if _, err = enc.w.Write(b); err != nil {
		enc.err = err
	}
	encodeStatePool.Put(e)
	return err
}
657476
func (enc *Encoder) Encode(v interface{}) error {
	if enc.err != nil {
		return enc.err
	}
	e := newEncodeState(enc.canonical)
	err := e.marshal(v)
	if err != nil {
		return err
	}

	if !enc.canonical {
		// 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.
		e.WriteByte('\n')
	}

	if _, err = enc.w.Write(e.Bytes()); err != nil {
		enc.err = err
	}
	encodeStatePool.Put(e)
	return err
}
90055
func (e *Encoder) Encode(event *watch.Event) error {
	data, err := runtime.Encode(e.embeddedEncoder, event.Object)
	if err != nil {
		return err
	}
	// FIXME: get rid of json.RawMessage.
	return e.encoder.Encode(&metav1.WatchEvent{
		Type:   string(event.Type),
		Object: runtime.RawExtension{Raw: json.RawMessage(data)},
	})
}
102151
func (e *LogEntry) Encode(w io.Writer) (int, error) {
	b, err := proto.Marshal(e.pb)
	if err != nil {
		return -1, err
	}

	if _, err = fmt.Fprintf(w, "%8x\n", len(b)); err != nil {
		return -1, err
	}

	return w.Write(b)
}
1206269
func Encode(ctx context.Context) ([]byte, error) {
	m := ToMap(ctx)
	if len(m) > 0 {
		return json.Marshal(m)
	}
	return nil, nil
}
730372
func Encode(in []byte) string {
	out := Client().Encode(in)
	Trace("Encode", nil, logrus.Fields{"in": in, "out": out})
	return out
}
214429
func (p *Pong) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w,
		p.PongBytes,
	)
}
1090047
func (e *Encoder) Encode(event Event) error {
	if event.ResetID || len(event.ID) > 0 {
		if err := e.WriteField("id", []byte(event.ID)); err != nil {
			return err
		}
	}

	if len(event.Retry) > 0 {
		if err := e.WriteField("retry", []byte(event.Retry)); err != nil {
			return err
		}
	}

	if len(event.Type) > 0 {
		if err := e.WriteField("event", []byte(event.Type)); err != nil {
			return err
		}
	}

	if err := e.WriteField("data", event.Data); err != nil {
		return err
	}

	return e.Flush()
}
958152
func Encode(buf []byte, code uint64) ([]byte, error) {

	if !ValidCode(code) {
		return nil, ErrUnknownCode
	}

	start := make([]byte, 2*binary.MaxVarintLen64, 2*binary.MaxVarintLen64+len(buf))
	spot := start
	n := binary.PutUvarint(spot, code)
	spot = start[n:]
	n += binary.PutUvarint(spot, uint64(len(buf)))

	return append(start[:n], buf...), nil
}