Check retval value and convert to error in generated RPC client code
[govpp.git] / binapi / nsh / nsh_rpc.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2
3 package nsh
4
5 import (
6         "context"
7         "fmt"
8         "io"
9
10         api "git.fd.io/govpp.git/api"
11         vpe "git.fd.io/govpp.git/binapi/vpe"
12 )
13
14 // RPCService defines RPC service nsh.
15 type RPCService interface {
16         NshAddDelEntry(ctx context.Context, in *NshAddDelEntry) (*NshAddDelEntryReply, error)
17         NshAddDelMap(ctx context.Context, in *NshAddDelMap) (*NshAddDelMapReply, error)
18         NshEntryDump(ctx context.Context, in *NshEntryDump) (RPCService_NshEntryDumpClient, error)
19         NshMapDump(ctx context.Context, in *NshMapDump) (RPCService_NshMapDumpClient, error)
20 }
21
22 type serviceClient struct {
23         conn api.Connection
24 }
25
26 func NewServiceClient(conn api.Connection) RPCService {
27         return &serviceClient{conn}
28 }
29
30 func (c *serviceClient) NshAddDelEntry(ctx context.Context, in *NshAddDelEntry) (*NshAddDelEntryReply, error) {
31         out := new(NshAddDelEntryReply)
32         err := c.conn.Invoke(ctx, in, out)
33         if err != nil {
34                 return nil, err
35         }
36         return out, api.RetvalToVPPApiError(out.Retval)
37 }
38
39 func (c *serviceClient) NshAddDelMap(ctx context.Context, in *NshAddDelMap) (*NshAddDelMapReply, error) {
40         out := new(NshAddDelMapReply)
41         err := c.conn.Invoke(ctx, in, out)
42         if err != nil {
43                 return nil, err
44         }
45         return out, api.RetvalToVPPApiError(out.Retval)
46 }
47
48 func (c *serviceClient) NshEntryDump(ctx context.Context, in *NshEntryDump) (RPCService_NshEntryDumpClient, error) {
49         stream, err := c.conn.NewStream(ctx)
50         if err != nil {
51                 return nil, err
52         }
53         x := &serviceClient_NshEntryDumpClient{stream}
54         if err := x.Stream.SendMsg(in); err != nil {
55                 return nil, err
56         }
57         if err = x.Stream.SendMsg(&vpe.ControlPing{}); err != nil {
58                 return nil, err
59         }
60         return x, nil
61 }
62
63 type RPCService_NshEntryDumpClient interface {
64         Recv() (*NshEntryDetails, error)
65         api.Stream
66 }
67
68 type serviceClient_NshEntryDumpClient struct {
69         api.Stream
70 }
71
72 func (c *serviceClient_NshEntryDumpClient) Recv() (*NshEntryDetails, error) {
73         msg, err := c.Stream.RecvMsg()
74         if err != nil {
75                 return nil, err
76         }
77         switch m := msg.(type) {
78         case *NshEntryDetails:
79                 return m, nil
80         case *vpe.ControlPingReply:
81                 return nil, io.EOF
82         default:
83                 return nil, fmt.Errorf("unexpected message: %T %v", m, m)
84         }
85 }
86
87 func (c *serviceClient) NshMapDump(ctx context.Context, in *NshMapDump) (RPCService_NshMapDumpClient, error) {
88         stream, err := c.conn.NewStream(ctx)
89         if err != nil {
90                 return nil, err
91         }
92         x := &serviceClient_NshMapDumpClient{stream}
93         if err := x.Stream.SendMsg(in); err != nil {
94                 return nil, err
95         }
96         if err = x.Stream.SendMsg(&vpe.ControlPing{}); err != nil {
97                 return nil, err
98         }
99         return x, nil
100 }
101
102 type RPCService_NshMapDumpClient interface {
103         Recv() (*NshMapDetails, error)
104         api.Stream
105 }
106
107 type serviceClient_NshMapDumpClient struct {
108         api.Stream
109 }
110
111 func (c *serviceClient_NshMapDumpClient) Recv() (*NshMapDetails, error) {
112         msg, err := c.Stream.RecvMsg()
113         if err != nil {
114                 return nil, err
115         }
116         switch m := msg.(type) {
117         case *NshMapDetails:
118                 return m, nil
119         case *vpe.ControlPingReply:
120                 return nil, io.EOF
121         default:
122                 return nil, fmt.Errorf("unexpected message: %T %v", m, m)
123         }
124 }