// Code generated by protoc-gen-go-drpc. DO NOT EDIT.
// protoc-gen-go-drpc version: v0.0.33
// source: tailnet/proto/tailnet.proto

package proto

import (
	context "context"
	errors "errors"
	protojson "google.golang.org/protobuf/encoding/protojson"
	proto "google.golang.org/protobuf/proto"
	drpc "storj.io/drpc"
	drpcerr "storj.io/drpc/drpcerr"
)

type drpcEncoding_File_tailnet_proto_tailnet_proto struct{}

func (drpcEncoding_File_tailnet_proto_tailnet_proto) Marshal(msg drpc.Message) ([]byte, error) {
	return proto.Marshal(msg.(proto.Message))
}

func (drpcEncoding_File_tailnet_proto_tailnet_proto) MarshalAppend(buf []byte, msg drpc.Message) ([]byte, error) {
	return proto.MarshalOptions{}.MarshalAppend(buf, msg.(proto.Message))
}

func (drpcEncoding_File_tailnet_proto_tailnet_proto) Unmarshal(buf []byte, msg drpc.Message) error {
	return proto.Unmarshal(buf, msg.(proto.Message))
}

func (drpcEncoding_File_tailnet_proto_tailnet_proto) JSONMarshal(msg drpc.Message) ([]byte, error) {
	return protojson.Marshal(msg.(proto.Message))
}

func (drpcEncoding_File_tailnet_proto_tailnet_proto) JSONUnmarshal(buf []byte, msg drpc.Message) error {
	return protojson.Unmarshal(buf, msg.(proto.Message))
}

type DRPCTailnetClient interface {
	DRPCConn() drpc.Conn

	StreamDERPMaps(ctx context.Context, in *StreamDERPMapsRequest) (DRPCTailnet_StreamDERPMapsClient, error)
	Coordinate(ctx context.Context) (DRPCTailnet_CoordinateClient, error)
}

type drpcTailnetClient struct {
	cc drpc.Conn
}

func NewDRPCTailnetClient(cc drpc.Conn) DRPCTailnetClient {
	return &drpcTailnetClient{cc}
}

func (c *drpcTailnetClient) DRPCConn() drpc.Conn { return c.cc }

func (c *drpcTailnetClient) StreamDERPMaps(ctx context.Context, in *StreamDERPMapsRequest) (DRPCTailnet_StreamDERPMapsClient, error) {
	stream, err := c.cc.NewStream(ctx, "/coder.tailnet.v2.Tailnet/StreamDERPMaps", drpcEncoding_File_tailnet_proto_tailnet_proto{})
	if err != nil {
		return nil, err
	}
	x := &drpcTailnet_StreamDERPMapsClient{stream}
	if err := x.MsgSend(in, drpcEncoding_File_tailnet_proto_tailnet_proto{}); err != nil {
		return nil, err
	}
	if err := x.CloseSend(); err != nil {
		return nil, err
	}
	return x, nil
}

type DRPCTailnet_StreamDERPMapsClient interface {
	drpc.Stream
	Recv() (*DERPMap, error)
}

type drpcTailnet_StreamDERPMapsClient struct {
	drpc.Stream
}

func (x *drpcTailnet_StreamDERPMapsClient) GetStream() drpc.Stream {
	return x.Stream
}

func (x *drpcTailnet_StreamDERPMapsClient) Recv() (*DERPMap, error) {
	m := new(DERPMap)
	if err := x.MsgRecv(m, drpcEncoding_File_tailnet_proto_tailnet_proto{}); err != nil {
		return nil, err
	}
	return m, nil
}

func (x *drpcTailnet_StreamDERPMapsClient) RecvMsg(m *DERPMap) error {
	return x.MsgRecv(m, drpcEncoding_File_tailnet_proto_tailnet_proto{})
}

func (c *drpcTailnetClient) Coordinate(ctx context.Context) (DRPCTailnet_CoordinateClient, error) {
	stream, err := c.cc.NewStream(ctx, "/coder.tailnet.v2.Tailnet/Coordinate", drpcEncoding_File_tailnet_proto_tailnet_proto{})
	if err != nil {
		return nil, err
	}
	x := &drpcTailnet_CoordinateClient{stream}
	return x, nil
}

type DRPCTailnet_CoordinateClient interface {
	drpc.Stream
	Send(*CoordinateRequest) error
	Recv() (*CoordinateResponse, error)
}

type drpcTailnet_CoordinateClient struct {
	drpc.Stream
}

func (x *drpcTailnet_CoordinateClient) GetStream() drpc.Stream {
	return x.Stream
}

func (x *drpcTailnet_CoordinateClient) Send(m *CoordinateRequest) error {
	return x.MsgSend(m, drpcEncoding_File_tailnet_proto_tailnet_proto{})
}

func (x *drpcTailnet_CoordinateClient) Recv() (*CoordinateResponse, error) {
	m := new(CoordinateResponse)
	if err := x.MsgRecv(m, drpcEncoding_File_tailnet_proto_tailnet_proto{}); err != nil {
		return nil, err
	}
	return m, nil
}

func (x *drpcTailnet_CoordinateClient) RecvMsg(m *CoordinateResponse) error {
	return x.MsgRecv(m, drpcEncoding_File_tailnet_proto_tailnet_proto{})
}

type DRPCTailnetServer interface {
	StreamDERPMaps(*StreamDERPMapsRequest, DRPCTailnet_StreamDERPMapsStream) error
	Coordinate(DRPCTailnet_CoordinateStream) error
}

type DRPCTailnetUnimplementedServer struct{}

func (s *DRPCTailnetUnimplementedServer) StreamDERPMaps(*StreamDERPMapsRequest, DRPCTailnet_StreamDERPMapsStream) error {
	return drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented)
}

func (s *DRPCTailnetUnimplementedServer) Coordinate(DRPCTailnet_CoordinateStream) error {
	return drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented)
}

type DRPCTailnetDescription struct{}

func (DRPCTailnetDescription) NumMethods() int { return 2 }

func (DRPCTailnetDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver, interface{}, bool) {
	switch n {
	case 0:
		return "/coder.tailnet.v2.Tailnet/StreamDERPMaps", drpcEncoding_File_tailnet_proto_tailnet_proto{},
			func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
				return nil, srv.(DRPCTailnetServer).
					StreamDERPMaps(
						in1.(*StreamDERPMapsRequest),
						&drpcTailnet_StreamDERPMapsStream{in2.(drpc.Stream)},
					)
			}, DRPCTailnetServer.StreamDERPMaps, true
	case 1:
		return "/coder.tailnet.v2.Tailnet/Coordinate", drpcEncoding_File_tailnet_proto_tailnet_proto{},
			func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
				return nil, srv.(DRPCTailnetServer).
					Coordinate(
						&drpcTailnet_CoordinateStream{in1.(drpc.Stream)},
					)
			}, DRPCTailnetServer.Coordinate, true
	default:
		return "", nil, nil, nil, false
	}
}

func DRPCRegisterTailnet(mux drpc.Mux, impl DRPCTailnetServer) error {
	return mux.Register(impl, DRPCTailnetDescription{})
}

type DRPCTailnet_StreamDERPMapsStream interface {
	drpc.Stream
	Send(*DERPMap) error
}

type drpcTailnet_StreamDERPMapsStream struct {
	drpc.Stream
}

func (x *drpcTailnet_StreamDERPMapsStream) Send(m *DERPMap) error {
	return x.MsgSend(m, drpcEncoding_File_tailnet_proto_tailnet_proto{})
}

type DRPCTailnet_CoordinateStream interface {
	drpc.Stream
	Send(*CoordinateResponse) error
	Recv() (*CoordinateRequest, error)
}

type drpcTailnet_CoordinateStream struct {
	drpc.Stream
}

func (x *drpcTailnet_CoordinateStream) Send(m *CoordinateResponse) error {
	return x.MsgSend(m, drpcEncoding_File_tailnet_proto_tailnet_proto{})
}

func (x *drpcTailnet_CoordinateStream) Recv() (*CoordinateRequest, error) {
	m := new(CoordinateRequest)
	if err := x.MsgRecv(m, drpcEncoding_File_tailnet_proto_tailnet_proto{}); err != nil {
		return nil, err
	}
	return m, nil
}

func (x *drpcTailnet_CoordinateStream) RecvMsg(m *CoordinateRequest) error {
	return x.MsgRecv(m, drpcEncoding_File_tailnet_proto_tailnet_proto{})
}
