MCPcopy
hub / github.com/wavetermdev/waveterm / recodeCommandData

Function recodeCommandData

pkg/wshutil/wshadapter.go:57–73  ·  view source on GitHub ↗
(command string, data any, commandDataType reflect.Type)

Source from the content-addressed store, hash-verified

55}
56
57func recodeCommandData(command string, data any, commandDataType reflect.Type) (any, error) {
58 if command == "" || commandDataType == nil {
59 return data, nil
60 }
61 methodDecl := WshCommandDeclMap[command]
62 if methodDecl == nil {
63 return data, fmt.Errorf("command %q not found", command)
64 }
65 commandDataPtr := reflect.New(commandDataType).Interface()
66 if data != nil {
67 err := utilfn.ReUnmarshal(commandDataPtr, data)
68 if err != nil {
69 return data, fmt.Errorf("error re-marshalling command data: %w", err)
70 }
71 }
72 return reflect.ValueOf(commandDataPtr).Elem().Interface(), nil
73}
74
75func serverImplAdapter(impl any) func(*RpcResponseHandler) bool {
76 if impl == nil {

Callers 1

serverImplAdapterFunction · 0.85

Calls 1

ReUnmarshalFunction · 0.92

Tested by

no test coverage detected