-
Notifications
You must be signed in to change notification settings - Fork 2
/
command.go
33 lines (27 loc) · 888 Bytes
/
command.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package plugin
type rpcMethod[T any] struct {
Name string `json:"name"`
Usage string `json:"usage"`
Description string `json:"description"`
LongDescription string `json:"long_description"`
callback RPCCommand[T] `json:"-"`
}
func (instance *rpcMethod[T]) Call(plugin *Plugin[T], request map[string]any) (map[string]any, error) {
return instance.callback.Call(plugin, request)
}
type rpcNotification[T any] struct {
onEvent string
callback RPCEvent[T]
}
func (instance *rpcNotification[T]) Call(plugin *Plugin[T], request map[string]any) {
instance.callback.Call(plugin, request)
}
type rpcHook[T any] struct {
name string
before []string
after []string
callback RPCCommand[T]
}
func (instance *rpcHook[T]) Call(plugin *Plugin[T], request map[string]any) {
instance.callback.Call(plugin, request)
}