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

     1  // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
     2  
     3  package udp
     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 udp.
    15  type RPCService interface {
    16  	UDPDecapAddDel(ctx context.Context, in *UDPDecapAddDel) (*UDPDecapAddDelReply, error)
    17  	UDPEncapAdd(ctx context.Context, in *UDPEncapAdd) (*UDPEncapAddReply, error)
    18  	UDPEncapDel(ctx context.Context, in *UDPEncapDel) (*UDPEncapDelReply, error)
    19  	UDPEncapDump(ctx context.Context, in *UDPEncapDump) (RPCService_UDPEncapDumpClient, 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) UDPDecapAddDel(ctx context.Context, in *UDPDecapAddDel) (*UDPDecapAddDelReply, error) {
    31  	out := new(UDPDecapAddDelReply)
    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) UDPEncapAdd(ctx context.Context, in *UDPEncapAdd) (*UDPEncapAddReply, error) {
    40  	out := new(UDPEncapAddReply)
    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) UDPEncapDel(ctx context.Context, in *UDPEncapDel) (*UDPEncapDelReply, error) {
    49  	out := new(UDPEncapDelReply)
    50  	err := c.conn.Invoke(ctx, in, out)
    51  	if err != nil {
    52  		return nil, err
    53  	}
    54  	return out, api.RetvalToVPPApiError(out.Retval)
    55  }
    56  
    57  func (c *serviceClient) UDPEncapDump(ctx context.Context, in *UDPEncapDump) (RPCService_UDPEncapDumpClient, error) {
    58  	stream, err := c.conn.NewStream(ctx)
    59  	if err != nil {
    60  		return nil, err
    61  	}
    62  	x := &serviceClient_UDPEncapDumpClient{stream}
    63  	if err := x.Stream.SendMsg(in); err != nil {
    64  		return nil, err
    65  	}
    66  	if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil {
    67  		return nil, err
    68  	}
    69  	return x, nil
    70  }
    71  
    72  type RPCService_UDPEncapDumpClient interface {
    73  	Recv() (*UDPEncapDetails, error)
    74  	api.Stream
    75  }
    76  
    77  type serviceClient_UDPEncapDumpClient struct {
    78  	api.Stream
    79  }
    80  
    81  func (c *serviceClient_UDPEncapDumpClient) Recv() (*UDPEncapDetails, error) {
    82  	msg, err := c.Stream.RecvMsg()
    83  	if err != nil {
    84  		return nil, err
    85  	}
    86  	switch m := msg.(type) {
    87  	case *UDPEncapDetails:
    88  		return m, nil
    89  	case *memclnt.ControlPingReply:
    90  		err = c.Stream.Close()
    91  		if err != nil {
    92  			return nil, err
    93  		}
    94  		return nil, io.EOF
    95  	default:
    96  		return nil, fmt.Errorf("unexpected message: %T %v", m, m)
    97  	}
    98  }