// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: proto/stream.proto

package stream

import (
	fmt "fmt"
	proto "google.golang.org/protobuf/proto"
	math "math"
)

import (
	context "context"
	api "go-micro.dev/v4/api"
	client "go-micro.dev/v4/client"
	server "go-micro.dev/v4/server"
)

// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf

// Reference imports to suppress errors if they are not otherwise used.
var _ api.Endpoint
var _ context.Context
var _ client.Option
var _ server.Option

// Api Endpoints for Streamer service

func NewStreamerEndpoints() []*api.Endpoint {
	return []*api.Endpoint{}
}

// Client API for Streamer service

type StreamerService interface {
	Stream(ctx context.Context, opts ...client.CallOption) (Streamer_StreamService, error)
	ServerStream(ctx context.Context, in *Request, opts ...client.CallOption) (Streamer_ServerStreamService, error)
}

type streamerService struct {
	c    client.Client
	name string
}

func NewStreamerService(name string, c client.Client) StreamerService {
	return &streamerService{
		c:    c,
		name: name,
	}
}

func (c *streamerService) Stream(ctx context.Context, opts ...client.CallOption) (Streamer_StreamService, error) {
	req := c.c.NewRequest(c.name, "Streamer.Stream", &Request{})
	stream, err := c.c.Stream(ctx, req, opts...)
	if err != nil {
		return nil, err
	}
	return &streamerServiceStream{stream}, nil
}

type Streamer_StreamService interface {
	Context() context.Context
	SendMsg(interface{}) error
	RecvMsg(interface{}) error
	CloseSend() error
	Close() error
	Send(*Request) error
	Recv() (*Response, error)
}

type streamerServiceStream struct {
	stream client.Stream
}

func (x *streamerServiceStream) CloseSend() error {
	return x.stream.CloseSend()
}

func (x *streamerServiceStream) Close() error {
	return x.stream.Close()
}

func (x *streamerServiceStream) Context() context.Context {
	return x.stream.Context()
}

func (x *streamerServiceStream) SendMsg(m interface{}) error {
	return x.stream.Send(m)
}

func (x *streamerServiceStream) RecvMsg(m interface{}) error {
	return x.stream.Recv(m)
}

func (x *streamerServiceStream) Send(m *Request) error {
	return x.stream.Send(m)
}

func (x *streamerServiceStream) Recv() (*Response, error) {
	m := new(Response)
	err := x.stream.Recv(m)
	if err != nil {
		return nil, err
	}
	return m, nil
}

func (c *streamerService) ServerStream(ctx context.Context, in *Request, opts ...client.CallOption) (Streamer_ServerStreamService, error) {
	req := c.c.NewRequest(c.name, "Streamer.ServerStream", &Request{})
	stream, err := c.c.Stream(ctx, req, opts...)
	if err != nil {
		return nil, err
	}
	if err := stream.Send(in); err != nil {
		return nil, err
	}
	return &streamerServiceServerStream{stream}, nil
}

type Streamer_ServerStreamService interface {
	Context() context.Context
	SendMsg(interface{}) error
	RecvMsg(interface{}) error
	CloseSend() error
	Close() error
	Recv() (*Response, error)
}

type streamerServiceServerStream struct {
	stream client.Stream
}

func (x *streamerServiceServerStream) CloseSend() error {
	return x.stream.CloseSend()
}

func (x *streamerServiceServerStream) Close() error {
	return x.stream.Close()
}

func (x *streamerServiceServerStream) Context() context.Context {
	return x.stream.Context()
}

func (x *streamerServiceServerStream) SendMsg(m interface{}) error {
	return x.stream.Send(m)
}

func (x *streamerServiceServerStream) RecvMsg(m interface{}) error {
	return x.stream.Recv(m)
}

func (x *streamerServiceServerStream) Recv() (*Response, error) {
	m := new(Response)
	err := x.stream.Recv(m)
	if err != nil {
		return nil, err
	}
	return m, nil
}

// Server API for Streamer service

type StreamerHandler interface {
	Stream(context.Context, Streamer_StreamStream) error
	ServerStream(context.Context, *Request, Streamer_ServerStreamStream) error
}

func RegisterStreamerHandler(s server.Server, hdlr StreamerHandler, opts ...server.HandlerOption) error {
	type streamer interface {
		Stream(ctx context.Context, stream server.Stream) error
		ServerStream(ctx context.Context, stream server.Stream) error
	}
	type Streamer struct {
		streamer
	}
	h := &streamerHandler{hdlr}
	return s.Handle(s.NewHandler(&Streamer{h}, opts...))
}

type streamerHandler struct {
	StreamerHandler
}

func (h *streamerHandler) Stream(ctx context.Context, stream server.Stream) error {
	return h.StreamerHandler.Stream(ctx, &streamerStreamStream{stream})
}

type Streamer_StreamStream interface {
	Context() context.Context
	SendMsg(interface{}) error
	RecvMsg(interface{}) error
	Close() error
	Send(*Response) error
	Recv() (*Request, error)
}

type streamerStreamStream struct {
	stream server.Stream
}

func (x *streamerStreamStream) Close() error {
	return x.stream.Close()
}

func (x *streamerStreamStream) Context() context.Context {
	return x.stream.Context()
}

func (x *streamerStreamStream) SendMsg(m interface{}) error {
	return x.stream.Send(m)
}

func (x *streamerStreamStream) RecvMsg(m interface{}) error {
	return x.stream.Recv(m)
}

func (x *streamerStreamStream) Send(m *Response) error {
	return x.stream.Send(m)
}

func (x *streamerStreamStream) Recv() (*Request, error) {
	m := new(Request)
	if err := x.stream.Recv(m); err != nil {
		return nil, err
	}
	return m, nil
}

func (h *streamerHandler) ServerStream(ctx context.Context, stream server.Stream) error {
	m := new(Request)
	if err := stream.Recv(m); err != nil {
		return err
	}
	return h.StreamerHandler.ServerStream(ctx, m, &streamerServerStreamStream{stream})
}

type Streamer_ServerStreamStream interface {
	Context() context.Context
	SendMsg(interface{}) error
	RecvMsg(interface{}) error
	Close() error
	Send(*Response) error
}

type streamerServerStreamStream struct {
	stream server.Stream
}

func (x *streamerServerStreamStream) Close() error {
	return x.stream.Close()
}

func (x *streamerServerStreamStream) Context() context.Context {
	return x.stream.Context()
}

func (x *streamerServerStreamStream) SendMsg(m interface{}) error {
	return x.stream.Send(m)
}

func (x *streamerServerStreamStream) RecvMsg(m interface{}) error {
	return x.stream.Recv(m)
}

func (x *streamerServerStreamStream) Send(m *Response) error {
	return x.stream.Send(m)
}
