2024-03-19 19:16:03 +08:00
|
|
|
package kis
|
|
|
|
|
|
|
|
import (
|
2024-04-16 14:58:00 +08:00
|
|
|
"reflect"
|
|
|
|
|
2024-03-26 14:54:50 +08:00
|
|
|
"github.com/aceld/kis-flow/common"
|
|
|
|
"github.com/aceld/kis-flow/serialize"
|
2024-03-19 19:16:03 +08:00
|
|
|
)
|
|
|
|
|
2024-04-15 17:50:02 +08:00
|
|
|
// Serialize Data serialization interface
|
2024-03-25 16:35:20 +08:00
|
|
|
type Serialize interface {
|
2024-04-15 17:50:02 +08:00
|
|
|
// UnMarshal is used to deserialize KisRowArr to a value of the specified type.
|
2024-03-25 16:35:20 +08:00
|
|
|
UnMarshal(common.KisRowArr, reflect.Type) (reflect.Value, error)
|
2024-04-15 17:50:02 +08:00
|
|
|
// Marshal is used to serialize a value of the specified type to KisRowArr.
|
2024-03-25 16:35:20 +08:00
|
|
|
Marshal(interface{}) (common.KisRowArr, error)
|
2024-03-19 19:16:03 +08:00
|
|
|
}
|
2024-03-21 10:13:32 +08:00
|
|
|
|
2024-04-15 17:50:02 +08:00
|
|
|
// defaultSerialize Default serialization implementation provided by KisFlow (developers can customize)
|
2024-03-25 16:35:20 +08:00
|
|
|
var defaultSerialize = &serialize.DefaultSerialize{}
|
2024-03-21 10:13:32 +08:00
|
|
|
|
2024-04-15 17:50:02 +08:00
|
|
|
// isSerialize checks if the provided paramType implements the Serialize interface
|
2024-03-25 16:35:20 +08:00
|
|
|
func isSerialize(paramType reflect.Type) bool {
|
|
|
|
return paramType.Implements(reflect.TypeOf((*Serialize)(nil)).Elem())
|
2024-03-21 10:13:32 +08:00
|
|
|
}
|