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

package directorytypes

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 (
	DirectoryService_Register_FullMethodName   = "/berty.directory.v1.DirectoryService/Register"
	DirectoryService_Query_FullMethodName      = "/berty.directory.v1.DirectoryService/Query"
	DirectoryService_Unregister_FullMethodName = "/berty.directory.v1.DirectoryService/Unregister"
)

// DirectoryServiceClient is the client API for DirectoryService 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.
//
// DirectoryService
type DirectoryServiceClient interface {
	Register(ctx context.Context, in *Register_Request, opts ...grpc.CallOption) (*Register_Reply, error)
	Query(ctx context.Context, in *Query_Request, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Query_Reply], error)
	Unregister(ctx context.Context, in *Unregister_Request, opts ...grpc.CallOption) (*Unregister_Reply, error)
}

type directoryServiceClient struct {
	cc grpc.ClientConnInterface
}

func NewDirectoryServiceClient(cc grpc.ClientConnInterface) DirectoryServiceClient {
	return &directoryServiceClient{cc}
}

func (c *directoryServiceClient) Register(ctx context.Context, in *Register_Request, opts ...grpc.CallOption) (*Register_Reply, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	out := new(Register_Reply)
	err := c.cc.Invoke(ctx, DirectoryService_Register_FullMethodName, in, out, cOpts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *directoryServiceClient) Query(ctx context.Context, in *Query_Request, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Query_Reply], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &DirectoryService_ServiceDesc.Streams[0], DirectoryService_Query_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[Query_Request, Query_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 DirectoryService_QueryClient = grpc.ServerStreamingClient[Query_Reply]

func (c *directoryServiceClient) Unregister(ctx context.Context, in *Unregister_Request, opts ...grpc.CallOption) (*Unregister_Reply, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	out := new(Unregister_Reply)
	err := c.cc.Invoke(ctx, DirectoryService_Unregister_FullMethodName, in, out, cOpts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

// DirectoryServiceServer is the server API for DirectoryService service.
// All implementations must embed UnimplementedDirectoryServiceServer
// for forward compatibility.
//
// DirectoryService
type DirectoryServiceServer interface {
	Register(context.Context, *Register_Request) (*Register_Reply, error)
	Query(*Query_Request, grpc.ServerStreamingServer[Query_Reply]) error
	Unregister(context.Context, *Unregister_Request) (*Unregister_Reply, error)
	mustEmbedUnimplementedDirectoryServiceServer()
}

// UnimplementedDirectoryServiceServer 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 UnimplementedDirectoryServiceServer struct{}

func (UnimplementedDirectoryServiceServer) Register(context.Context, *Register_Request) (*Register_Reply, error) {
	return nil, status.Errorf(codes.Unimplemented, "method Register not implemented")
}
func (UnimplementedDirectoryServiceServer) Query(*Query_Request, grpc.ServerStreamingServer[Query_Reply]) error {
	return status.Errorf(codes.Unimplemented, "method Query not implemented")
}
func (UnimplementedDirectoryServiceServer) Unregister(context.Context, *Unregister_Request) (*Unregister_Reply, error) {
	return nil, status.Errorf(codes.Unimplemented, "method Unregister not implemented")
}
func (UnimplementedDirectoryServiceServer) mustEmbedUnimplementedDirectoryServiceServer() {}
func (UnimplementedDirectoryServiceServer) testEmbeddedByValue()                          {}

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

func RegisterDirectoryServiceServer(s grpc.ServiceRegistrar, srv DirectoryServiceServer) {
	// If the following call pancis, it indicates UnimplementedDirectoryServiceServer 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(&DirectoryService_ServiceDesc, srv)
}

func _DirectoryService_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(Register_Request)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(DirectoryServiceServer).Register(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: DirectoryService_Register_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(DirectoryServiceServer).Register(ctx, req.(*Register_Request))
	}
	return interceptor(ctx, in, info, handler)
}

func _DirectoryService_Query_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(Query_Request)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(DirectoryServiceServer).Query(m, &grpc.GenericServerStream[Query_Request, Query_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 DirectoryService_QueryServer = grpc.ServerStreamingServer[Query_Reply]

func _DirectoryService_Unregister_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(Unregister_Request)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(DirectoryServiceServer).Unregister(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: DirectoryService_Unregister_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(DirectoryServiceServer).Unregister(ctx, req.(*Unregister_Request))
	}
	return interceptor(ctx, in, info, handler)
}

// DirectoryService_ServiceDesc is the grpc.ServiceDesc for DirectoryService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var DirectoryService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "berty.directory.v1.DirectoryService",
	HandlerType: (*DirectoryServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Register",
			Handler:    _DirectoryService_Register_Handler,
		},
		{
			MethodName: "Unregister",
			Handler:    _DirectoryService_Unregister_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Query",
			Handler:       _DirectoryService_Query_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "directorytypes/bertydirectory.proto",
}
