-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
notify_saltpack.go
138 lines (121 loc) · 4.32 KB
/
notify_saltpack.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/keybase1/notify_saltpack.avdl
package keybase1
import (
"fmt"
"github.com/keybase/go-framed-msgpack-rpc/rpc"
context "golang.org/x/net/context"
"time"
)
type SaltpackOperationType int
const (
SaltpackOperationType_ENCRYPT SaltpackOperationType = 0
SaltpackOperationType_DECRYPT SaltpackOperationType = 1
SaltpackOperationType_SIGN SaltpackOperationType = 2
SaltpackOperationType_VERIFY SaltpackOperationType = 3
)
func (o SaltpackOperationType) DeepCopy() SaltpackOperationType { return o }
var SaltpackOperationTypeMap = map[string]SaltpackOperationType{
"ENCRYPT": 0,
"DECRYPT": 1,
"SIGN": 2,
"VERIFY": 3,
}
var SaltpackOperationTypeRevMap = map[SaltpackOperationType]string{
0: "ENCRYPT",
1: "DECRYPT",
2: "SIGN",
3: "VERIFY",
}
func (e SaltpackOperationType) String() string {
if v, ok := SaltpackOperationTypeRevMap[e]; ok {
return v
}
return fmt.Sprintf("%v", int(e))
}
type SaltpackOperationStartArg struct {
OpType SaltpackOperationType `codec:"opType" json:"opType"`
Filename string `codec:"filename" json:"filename"`
}
type SaltpackOperationProgressArg struct {
OpType SaltpackOperationType `codec:"opType" json:"opType"`
Filename string `codec:"filename" json:"filename"`
BytesComplete int64 `codec:"bytesComplete" json:"bytesComplete"`
BytesTotal int64 `codec:"bytesTotal" json:"bytesTotal"`
}
type SaltpackOperationDoneArg struct {
OpType SaltpackOperationType `codec:"opType" json:"opType"`
Filename string `codec:"filename" json:"filename"`
}
type NotifySaltpackInterface interface {
SaltpackOperationStart(context.Context, SaltpackOperationStartArg) error
SaltpackOperationProgress(context.Context, SaltpackOperationProgressArg) error
SaltpackOperationDone(context.Context, SaltpackOperationDoneArg) error
}
func NotifySaltpackProtocol(i NotifySaltpackInterface) rpc.Protocol {
return rpc.Protocol{
Name: "keybase.1.NotifySaltpack",
Methods: map[string]rpc.ServeHandlerDescription{
"saltpackOperationStart": {
MakeArg: func() interface{} {
var ret [1]SaltpackOperationStartArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]SaltpackOperationStartArg)
if !ok {
err = rpc.NewTypeError((*[1]SaltpackOperationStartArg)(nil), args)
return
}
err = i.SaltpackOperationStart(ctx, typedArgs[0])
return
},
},
"saltpackOperationProgress": {
MakeArg: func() interface{} {
var ret [1]SaltpackOperationProgressArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]SaltpackOperationProgressArg)
if !ok {
err = rpc.NewTypeError((*[1]SaltpackOperationProgressArg)(nil), args)
return
}
err = i.SaltpackOperationProgress(ctx, typedArgs[0])
return
},
},
"saltpackOperationDone": {
MakeArg: func() interface{} {
var ret [1]SaltpackOperationDoneArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]SaltpackOperationDoneArg)
if !ok {
err = rpc.NewTypeError((*[1]SaltpackOperationDoneArg)(nil), args)
return
}
err = i.SaltpackOperationDone(ctx, typedArgs[0])
return
},
},
},
}
}
type NotifySaltpackClient struct {
Cli rpc.GenericClient
}
func (c NotifySaltpackClient) SaltpackOperationStart(ctx context.Context, __arg SaltpackOperationStartArg) (err error) {
err = c.Cli.Notify(ctx, "keybase.1.NotifySaltpack.saltpackOperationStart", []interface{}{__arg}, 0*time.Millisecond)
return
}
func (c NotifySaltpackClient) SaltpackOperationProgress(ctx context.Context, __arg SaltpackOperationProgressArg) (err error) {
err = c.Cli.Notify(ctx, "keybase.1.NotifySaltpack.saltpackOperationProgress", []interface{}{__arg}, 0*time.Millisecond)
return
}
func (c NotifySaltpackClient) SaltpackOperationDone(ctx context.Context, __arg SaltpackOperationDoneArg) (err error) {
err = c.Cli.Notify(ctx, "keybase.1.NotifySaltpack.saltpackOperationDone", []interface{}{__arg}, 0*time.Millisecond)
return
}