github.com/edwarnicke/govpp@v0.0.0-20230130211138-14ef5d20b1d0/binapi/nsh/nsh_rpc.ba.go (about)

     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  	memclnt "github.com/edwarnicke/govpp/binapi/memclnt"
    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(&memclnt.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 *memclnt.ControlPingReply:
    81  		err = c.Stream.Close()
    82  		if err != nil {
    83  			return nil, err
    84  		}
    85  		return nil, io.EOF
    86  	default:
    87  		return nil, fmt.Errorf("unexpected message: %T %v", m, m)
    88  	}
    89  }
    90  
    91  func (c *serviceClient) NshMapDump(ctx context.Context, in *NshMapDump) (RPCService_NshMapDumpClient, error) {
    92  	stream, err := c.conn.NewStream(ctx)
    93  	if err != nil {
    94  		return nil, err
    95  	}
    96  	x := &serviceClient_NshMapDumpClient{stream}
    97  	if err := x.Stream.SendMsg(in); err != nil {
    98  		return nil, err
    99  	}
   100  	if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil {
   101  		return nil, err
   102  	}
   103  	return x, nil
   104  }
   105  
   106  type RPCService_NshMapDumpClient interface {
   107  	Recv() (*NshMapDetails, error)
   108  	api.Stream
   109  }
   110  
   111  type serviceClient_NshMapDumpClient struct {
   112  	api.Stream
   113  }
   114  
   115  func (c *serviceClient_NshMapDumpClient) Recv() (*NshMapDetails, error) {
   116  	msg, err := c.Stream.RecvMsg()
   117  	if err != nil {
   118  		return nil, err
   119  	}
   120  	switch m := msg.(type) {
   121  	case *NshMapDetails:
   122  		return m, nil
   123  	case *memclnt.ControlPingReply:
   124  		err = c.Stream.Close()
   125  		if err != nil {
   126  			return nil, err
   127  		}
   128  		return nil, io.EOF
   129  	default:
   130  		return nil, fmt.Errorf("unexpected message: %T %v", m, m)
   131  	}
   132  }