// EncodePresenceResult ...
510732
func (e *JSONEncoder) EncodePresence(res *PresenceResult) ([]byte, error) {
	return json.Marshal(res)
}
782057
func Encode(e Encoder, obj Object) ([]byte, error) {
	return e.Encode(obj)
}
1036617
func (e *Encoder) Encode(v interface{}) (err error) {
	defer func() {
		if r := recover(); r != nil {
			if _, ok := r.(runtime.Error); ok {
				panic(r)
			}
			if s, ok := r.(string); ok {
				panic(s)
			}
			err = r.(error)
		}
	}()
	e.b.Clear()
	reflectValue(&e.b, reflect.ValueOf(v), encoderOptions{})
	if _, err := e.b.WriteTo(e.w); err != nil {
		return WithStack(err)
	}
	return nil
}
837831
func NewResult(version string, resultBytes []byte) (types.Result, error) {
	reconciler := &Reconciler{}
	for _, resultFactory := range resultFactories {
		err := reconciler.CheckRaw(version, resultFactory.supportedVersions)
		if err == nil {
			// Result supports this version
			return resultFactory.newResult(resultBytes)
		}
	}

	return nil, fmt.Errorf("unsupported CNI result version %q", version)
}
1262680
func formatResult(results []*ldap.Entry) string {
	var names []string
	for _, entry := range results {
		names = append(names, entry.DN)
	}
	return "\t" + strings.Join(names[0:10], "\n\t")
}
893402
func (d *GetResult) Decode(valuePtr interface{}, decode Decode) error {
	if decode == nil {
		decode = DefaultDecode
	}
	return decode(d.contents, d.flags, valuePtr)
}
680075
func (r *ReferenceUpdateRequest) Encode(w io.Writer) error {
	if err := r.validate(); err != nil {
		return err
	}

	e := pktline.NewEncoder(w)

	if err := r.encodeShallow(e, r.Shallow); err != nil {
		return err
	}

	if err := r.encodeCommands(e, r.Commands, r.Capabilities); err != nil {
		return err
	}

	if r.Packfile != nil {
		if _, err := io.Copy(w, r.Packfile); err != nil {
			return err
		}

		return r.Packfile.Close()
	}

	return nil
}
327906
func (enc *ICalEncode) Encode(c ICalEmiter) {
	component := c.EmitICal()
	component.Write(enc)
}
1097145
func EncodeResponse(cached *CachedResponse, writer io.Writer) error {
	return gob.NewEncoder(writer).Encode(cached)
}
659009
func (cf *concatFunction) GetResult(evalCtx *AggEvaluateContext) (d types.Datum) {
	if evalCtx.Buffer != nil {
		d.SetString(evalCtx.Buffer.String())
	} else {
		d.SetNull()
	}
	return d
}
613944
func (m *CreateSessionReply) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w,
		m.Code,
		m.LastApplied,
		m.Data,
	)
}
1311803
func (w *walletAPIHandler) encodeResult(call Call, result interface{}, wr io.Writer) error {
	return encodeResult(call, result, wr, w.indent)
}
791005
func (f *FailIncorrectCltvExpiry) Encode(w io.Writer, pver uint32) error {
	if err := WriteElement(w, f.CltvExpiry); err != nil {
		return err
	}

	return writeOnionErrorChanUpdate(w, &f.Update, pver)
}
529046
func encodeInvCursor(cur *internal.InvocationsCursor) (string, error) {
	if cur.LastScanned == 0 {
		return "", nil
	}

	blob, err := proto.Marshal(cur)
	if err != nil {
		return "", err // must never actually happen
	}

	return base64.RawURLEncoding.EncodeToString(blob), nil
}
696781
func (typedData *TypedData) EncodePrimitiveValue(encType string, encValue interface{}, depth int) ([]byte, error) {

	switch encType {
	case "address":
		stringValue, ok := encValue.(string)
		if !ok || !common.IsHexAddress(stringValue) {
			return nil, dataMismatchError(encType, encValue)
		}
		retval := make([]byte, 32)
		copy(retval[12:], common.HexToAddress(stringValue).Bytes())
		return retval, nil
	case "bool":
		boolValue, ok := encValue.(bool)
		if !ok {
			return nil, dataMismatchError(encType, encValue)
		}
		if boolValue {
			return math.PaddedBigBytes(common.Big1, 32), nil
		}
		return math.PaddedBigBytes(common.Big0, 32), nil
	case "string":
		strVal, ok := encValue.(string)
		if !ok {
			return nil, dataMismatchError(encType, encValue)
		}
		return crypto.Keccak256([]byte(strVal)), nil
	case "bytes":
		bytesValue, ok := encValue.([]byte)
		if !ok {
			return nil, dataMismatchError(encType, encValue)
		}
		return crypto.Keccak256(bytesValue), nil
	}
	if strings.HasPrefix(encType, "bytes") {
		lengthStr := strings.TrimPrefix(encType, "bytes")
		length, err := strconv.Atoi(lengthStr)
		if err != nil {
			return nil, fmt.Errorf("invalid size on bytes: %v", lengthStr)
		}
		if length < 0 || length > 32 {
			return nil, fmt.Errorf("invalid size on bytes: %d", length)
		}
		if byteValue, ok := encValue.(hexutil.Bytes); !ok {
			return nil, dataMismatchError(encType, encValue)
		} else {
			return math.PaddedBigBytes(new(big.Int).SetBytes(byteValue), 32), nil
		}
	}
	if strings.HasPrefix(encType, "int") || strings.HasPrefix(encType, "uint") {
		length := 0
		if encType == "int" || encType == "uint" {
			length = 256
		} else {
			lengthStr := ""
			if strings.HasPrefix(encType, "uint") {
				lengthStr = strings.TrimPrefix(encType, "uint")
			} else {
				lengthStr = strings.TrimPrefix(encType, "int")
			}
			atoiSize, err := strconv.Atoi(lengthStr)
			if err != nil {
				return nil, fmt.Errorf("invalid size on integer: %v", lengthStr)
			}
			length = atoiSize
		}
		bigIntValue, ok := encValue.(*big.Int)
		if bigIntValue.BitLen() > length {
			return nil, fmt.Errorf("integer larger than '%v'", encType)
		}
		if !ok {
			return nil, dataMismatchError(encType, encValue)
		}
		return abi.U256(bigIntValue), nil
	}
	return nil, fmt.Errorf("unrecognized type '%s'", encType)

}
1342479
func Encode(w io.Writer, src image.Image, opt *EncoderOptions) (err error) {
	// Recover panic
	defer func() {
		if r := recover(); r != nil {
			var ok bool
			err, ok = r.(error)
			if !ok {
				err = fmt.Errorf("JPEG error: %v", r)
			}
		}
	}()

	cinfo := C.new_compress()
	defer C.destroy_compress(cinfo)

	dstManager := makeDestinationManager(w, cinfo)
	defer releaseDestinationManager(dstManager)

	switch s := src.(type) {
	case *image.YCbCr:
		err = encodeYCbCr(cinfo, s, opt)
	case *image.Gray:
		err = encodeGray(cinfo, s, opt)
	case *image.RGBA:
		err = encodeRGBA(cinfo, s, opt)
	default:
		return errors.New("unsupported image type")
	}

	return
}
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
}