github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/protocol/keybase1/test.go (about) 1 // Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler) 2 // Input file: avdl/keybase1/test.avdl 3 4 package keybase1 5 6 import ( 7 "github.com/keybase/go-framed-msgpack-rpc/rpc" 8 context "golang.org/x/net/context" 9 "time" 10 ) 11 12 // Result from calling test(..). 13 type Test struct { 14 Reply string `codec:"reply" json:"reply"` 15 } 16 17 func (o Test) DeepCopy() Test { 18 return Test{ 19 Reply: o.Reply, 20 } 21 } 22 23 type Generic struct { 24 M map[string]Generic `codec:"m" json:"m"` 25 A []Generic `codec:"a" json:"a"` 26 S *string `codec:"s,omitempty" json:"s,omitempty"` 27 I *int `codec:"i,omitempty" json:"i,omitempty"` 28 } 29 30 func (o Generic) DeepCopy() Generic { 31 return Generic{ 32 M: (func(x map[string]Generic) map[string]Generic { 33 if x == nil { 34 return nil 35 } 36 ret := make(map[string]Generic, len(x)) 37 for k, v := range x { 38 kCopy := k 39 vCopy := v.DeepCopy() 40 ret[kCopy] = vCopy 41 } 42 return ret 43 })(o.M), 44 A: (func(x []Generic) []Generic { 45 if x == nil { 46 return nil 47 } 48 ret := make([]Generic, len(x)) 49 for i, v := range x { 50 vCopy := v.DeepCopy() 51 ret[i] = vCopy 52 } 53 return ret 54 })(o.A), 55 S: (func(x *string) *string { 56 if x == nil { 57 return nil 58 } 59 tmp := (*x) 60 return &tmp 61 })(o.S), 62 I: (func(x *int) *int { 63 if x == nil { 64 return nil 65 } 66 tmp := (*x) 67 return &tmp 68 })(o.I), 69 } 70 } 71 72 type TestArg struct { 73 SessionID int `codec:"sessionID" json:"sessionID"` 74 Name string `codec:"name" json:"name"` 75 } 76 77 type TestCallbackArg struct { 78 SessionID int `codec:"sessionID" json:"sessionID"` 79 Name string `codec:"name" json:"name"` 80 } 81 82 type PanicArg struct { 83 Message string `codec:"message" json:"message"` 84 } 85 86 type TestAirdropRegArg struct { 87 } 88 89 type EchoArg struct { 90 Arg Generic `codec:"arg" json:"arg"` 91 } 92 93 type TestInterface interface { 94 // Call test method. 95 // Will trigger the testCallback method, whose result will be set in the 96 // returned Test object, reply property. 97 Test(context.Context, TestArg) (Test, error) 98 // This is a service callback triggered from test(..). 99 // The name param is what was passed into test. 100 TestCallback(context.Context, TestCallbackArg) (string, error) 101 // For testing crashes. 102 Panic(context.Context, string) error 103 // For testing airdrop reg. 104 TestAirdropReg(context.Context) error 105 Echo(context.Context, Generic) (Generic, error) 106 } 107 108 func TestProtocol(i TestInterface) rpc.Protocol { 109 return rpc.Protocol{ 110 Name: "keybase.1.test", 111 Methods: map[string]rpc.ServeHandlerDescription{ 112 "test": { 113 MakeArg: func() interface{} { 114 var ret [1]TestArg 115 return &ret 116 }, 117 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 118 typedArgs, ok := args.(*[1]TestArg) 119 if !ok { 120 err = rpc.NewTypeError((*[1]TestArg)(nil), args) 121 return 122 } 123 ret, err = i.Test(ctx, typedArgs[0]) 124 return 125 }, 126 }, 127 "testCallback": { 128 MakeArg: func() interface{} { 129 var ret [1]TestCallbackArg 130 return &ret 131 }, 132 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 133 typedArgs, ok := args.(*[1]TestCallbackArg) 134 if !ok { 135 err = rpc.NewTypeError((*[1]TestCallbackArg)(nil), args) 136 return 137 } 138 ret, err = i.TestCallback(ctx, typedArgs[0]) 139 return 140 }, 141 }, 142 "panic": { 143 MakeArg: func() interface{} { 144 var ret [1]PanicArg 145 return &ret 146 }, 147 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 148 typedArgs, ok := args.(*[1]PanicArg) 149 if !ok { 150 err = rpc.NewTypeError((*[1]PanicArg)(nil), args) 151 return 152 } 153 err = i.Panic(ctx, typedArgs[0].Message) 154 return 155 }, 156 }, 157 "testAirdropReg": { 158 MakeArg: func() interface{} { 159 var ret [1]TestAirdropRegArg 160 return &ret 161 }, 162 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 163 err = i.TestAirdropReg(ctx) 164 return 165 }, 166 }, 167 "echo": { 168 MakeArg: func() interface{} { 169 var ret [1]EchoArg 170 return &ret 171 }, 172 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 173 typedArgs, ok := args.(*[1]EchoArg) 174 if !ok { 175 err = rpc.NewTypeError((*[1]EchoArg)(nil), args) 176 return 177 } 178 ret, err = i.Echo(ctx, typedArgs[0].Arg) 179 return 180 }, 181 }, 182 }, 183 } 184 } 185 186 type TestClient struct { 187 Cli rpc.GenericClient 188 } 189 190 // Call test method. 191 // Will trigger the testCallback method, whose result will be set in the 192 // returned Test object, reply property. 193 func (c TestClient) Test(ctx context.Context, __arg TestArg) (res Test, err error) { 194 err = c.Cli.Call(ctx, "keybase.1.test.test", []interface{}{__arg}, &res, 0*time.Millisecond) 195 return 196 } 197 198 // This is a service callback triggered from test(..). 199 // The name param is what was passed into test. 200 func (c TestClient) TestCallback(ctx context.Context, __arg TestCallbackArg) (res string, err error) { 201 err = c.Cli.Call(ctx, "keybase.1.test.testCallback", []interface{}{__arg}, &res, 0*time.Millisecond) 202 return 203 } 204 205 // For testing crashes. 206 func (c TestClient) Panic(ctx context.Context, message string) (err error) { 207 __arg := PanicArg{Message: message} 208 err = c.Cli.Call(ctx, "keybase.1.test.panic", []interface{}{__arg}, nil, 0*time.Millisecond) 209 return 210 } 211 212 // For testing airdrop reg. 213 func (c TestClient) TestAirdropReg(ctx context.Context) (err error) { 214 err = c.Cli.Call(ctx, "keybase.1.test.testAirdropReg", []interface{}{TestAirdropRegArg{}}, nil, 0*time.Millisecond) 215 return 216 } 217 218 func (c TestClient) Echo(ctx context.Context, arg Generic) (res Generic, err error) { 219 __arg := EchoArg{Arg: arg} 220 err = c.Cli.Call(ctx, "keybase.1.test.echo", []interface{}{__arg}, &res, 0*time.Millisecond) 221 return 222 }