// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc             (unknown)
// source: go-internal/testutil.proto

package testutil

import (
	context "context"
	grpc "google.golang.org/grpc"
	codes "google.golang.org/grpc/codes"
	status "google.golang.org/grpc/status"
)

// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9

const (
	TestService_EchoTest_FullMethodName       = "/testutil.TestService/EchoTest"
	TestService_EchoStreamTest_FullMethodName = "/testutil.TestService/EchoStreamTest"
	TestService_EchoDuplexTest_FullMethodName = "/testutil.TestService/EchoDuplexTest"
)

// TestServiceClient is the client API for TestService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type TestServiceClient interface {
	// use to test unary
	EchoTest(ctx context.Context, in *EchoTest_Request, opts ...grpc.CallOption) (*EchoTest_Reply, error)
	// Use to test stream.
	EchoStreamTest(ctx context.Context, in *EchoStreamTest_Request, opts ...grpc.CallOption) (grpc.ServerStreamingClient[EchoStreamTest_Reply], error)
	// Use to test duplex stream.
	EchoDuplexTest(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[EchoDuplexTest_Request, EchoDuplexTest_Reply], error)
}

type testServiceClient struct {
	cc grpc.ClientConnInterface
}

func NewTestServiceClient(cc grpc.ClientConnInterface) TestServiceClient {
	return &testServiceClient{cc}
}

func (c *testServiceClient) EchoTest(ctx context.Context, in *EchoTest_Request, opts ...grpc.CallOption) (*EchoTest_Reply, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	out := new(EchoTest_Reply)
	err := c.cc.Invoke(ctx, TestService_EchoTest_FullMethodName, in, out, cOpts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *testServiceClient) EchoStreamTest(ctx context.Context, in *EchoStreamTest_Request, opts ...grpc.CallOption) (grpc.ServerStreamingClient[EchoStreamTest_Reply], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[0], TestService_EchoStreamTest_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[EchoStreamTest_Request, EchoStreamTest_Reply]{ClientStream: stream}
	if err := x.ClientStream.SendMsg(in); err != nil {
		return nil, err
	}
	if err := x.ClientStream.CloseSend(); err != nil {
		return nil, err
	}
	return x, nil
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type TestService_EchoStreamTestClient = grpc.ServerStreamingClient[EchoStreamTest_Reply]

func (c *testServiceClient) EchoDuplexTest(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[EchoDuplexTest_Request, EchoDuplexTest_Reply], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[1], TestService_EchoDuplexTest_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[EchoDuplexTest_Request, EchoDuplexTest_Reply]{ClientStream: stream}
	return x, nil
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type TestService_EchoDuplexTestClient = grpc.BidiStreamingClient[EchoDuplexTest_Request, EchoDuplexTest_Reply]

// TestServiceServer is the server API for TestService service.
// All implementations must embed UnimplementedTestServiceServer
// for forward compatibility.
type TestServiceServer interface {
	// use to test unary
	EchoTest(context.Context, *EchoTest_Request) (*EchoTest_Reply, error)
	// Use to test stream.
	EchoStreamTest(*EchoStreamTest_Request, grpc.ServerStreamingServer[EchoStreamTest_Reply]) error
	// Use to test duplex stream.
	EchoDuplexTest(grpc.BidiStreamingServer[EchoDuplexTest_Request, EchoDuplexTest_Reply]) error
	mustEmbedUnimplementedTestServiceServer()
}

// UnimplementedTestServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedTestServiceServer struct{}

func (UnimplementedTestServiceServer) EchoTest(context.Context, *EchoTest_Request) (*EchoTest_Reply, error) {
	return nil, status.Errorf(codes.Unimplemented, "method EchoTest not implemented")
}
func (UnimplementedTestServiceServer) EchoStreamTest(*EchoStreamTest_Request, grpc.ServerStreamingServer[EchoStreamTest_Reply]) error {
	return status.Errorf(codes.Unimplemented, "method EchoStreamTest not implemented")
}
func (UnimplementedTestServiceServer) EchoDuplexTest(grpc.BidiStreamingServer[EchoDuplexTest_Request, EchoDuplexTest_Reply]) error {
	return status.Errorf(codes.Unimplemented, "method EchoDuplexTest not implemented")
}
func (UnimplementedTestServiceServer) mustEmbedUnimplementedTestServiceServer() {}
func (UnimplementedTestServiceServer) testEmbeddedByValue()                     {}

// UnsafeTestServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to TestServiceServer will
// result in compilation errors.
type UnsafeTestServiceServer interface {
	mustEmbedUnimplementedTestServiceServer()
}

func RegisterTestServiceServer(s grpc.ServiceRegistrar, srv TestServiceServer) {
	// If the following call pancis, it indicates UnimplementedTestServiceServer was
	// embedded by pointer and is nil.  This will cause panics if an
	// unimplemented method is ever invoked, so we test this at initialization
	// time to prevent it from happening at runtime later due to I/O.
	if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
		t.testEmbeddedByValue()
	}
	s.RegisterService(&TestService_ServiceDesc, srv)
}

func _TestService_EchoTest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(EchoTest_Request)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(TestServiceServer).EchoTest(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: TestService_EchoTest_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(TestServiceServer).EchoTest(ctx, req.(*EchoTest_Request))
	}
	return interceptor(ctx, in, info, handler)
}

func _TestService_EchoStreamTest_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(EchoStreamTest_Request)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(TestServiceServer).EchoStreamTest(m, &grpc.GenericServerStream[EchoStreamTest_Request, EchoStreamTest_Reply]{ServerStream: stream})
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type TestService_EchoStreamTestServer = grpc.ServerStreamingServer[EchoStreamTest_Reply]

func _TestService_EchoDuplexTest_Handler(srv interface{}, stream grpc.ServerStream) error {
	return srv.(TestServiceServer).EchoDuplexTest(&grpc.GenericServerStream[EchoDuplexTest_Request, EchoDuplexTest_Reply]{ServerStream: stream})
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type TestService_EchoDuplexTestServer = grpc.BidiStreamingServer[EchoDuplexTest_Request, EchoDuplexTest_Reply]

// TestService_ServiceDesc is the grpc.ServiceDesc for TestService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var TestService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "testutil.TestService",
	HandlerType: (*TestServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "EchoTest",
			Handler:    _TestService_EchoTest_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "EchoStreamTest",
			Handler:       _TestService_EchoStreamTest_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "EchoDuplexTest",
			Handler:       _TestService_EchoDuplexTest_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "go-internal/testutil.proto",
}
