kis-flow/kis/serialize.go

25 lines
818 B
Go
Raw Normal View History

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
type Serialize interface {
2024-04-15 17:50:02 +08:00
// UnMarshal is used to deserialize KisRowArr to a value of the specified type.
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.
Marshal(interface{}) (common.KisRowArr, error)
2024-03-19 19:16:03 +08:00
}
2024-04-15 17:50:02 +08:00
// defaultSerialize Default serialization implementation provided by KisFlow (developers can customize)
var defaultSerialize = &serialize.DefaultSerialize{}
2024-04-15 17:50:02 +08:00
// isSerialize checks if the provided paramType implements the Serialize interface
func isSerialize(paramType reflect.Type) bool {
return paramType.Implements(reflect.TypeOf((*Serialize)(nil)).Elem())
}