// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc             v3.12.4
// source: filehandler.proto

package filehandler

import (
	context "context"
	common "github.com/thomas-osgood/OGOR/protobufs/definitions/common"
	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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7

// FileserviceClient is the client API for Fileservice 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 FileserviceClient interface {
	// rpc designed to upload a file from the machine the
	// client is running on to the server.
	DownloadFile(ctx context.Context, opts ...grpc.CallOption) (Fileservice_DownloadFileClient, error)
	// rpc designed to download a file to the machine the
	// client is running on from the server.
	UploadFile(ctx context.Context, in *FileRequest, opts ...grpc.CallOption) (Fileservice_UploadFileClient, error)
}

type fileserviceClient struct {
	cc grpc.ClientConnInterface
}

func NewFileserviceClient(cc grpc.ClientConnInterface) FileserviceClient {
	return &fileserviceClient{cc}
}

func (c *fileserviceClient) DownloadFile(ctx context.Context, opts ...grpc.CallOption) (Fileservice_DownloadFileClient, error) {
	stream, err := c.cc.NewStream(ctx, &Fileservice_ServiceDesc.Streams[0], "/filehandler.Fileservice/DownloadFile", opts...)
	if err != nil {
		return nil, err
	}
	x := &fileserviceDownloadFileClient{stream}
	return x, nil
}

type Fileservice_DownloadFileClient interface {
	Send(*FileChunk) error
	CloseAndRecv() (*common.StatusMessage, error)
	grpc.ClientStream
}

type fileserviceDownloadFileClient struct {
	grpc.ClientStream
}

func (x *fileserviceDownloadFileClient) Send(m *FileChunk) error {
	return x.ClientStream.SendMsg(m)
}

func (x *fileserviceDownloadFileClient) CloseAndRecv() (*common.StatusMessage, error) {
	if err := x.ClientStream.CloseSend(); err != nil {
		return nil, err
	}
	m := new(common.StatusMessage)
	if err := x.ClientStream.RecvMsg(m); err != nil {
		return nil, err
	}
	return m, nil
}

func (c *fileserviceClient) UploadFile(ctx context.Context, in *FileRequest, opts ...grpc.CallOption) (Fileservice_UploadFileClient, error) {
	stream, err := c.cc.NewStream(ctx, &Fileservice_ServiceDesc.Streams[1], "/filehandler.Fileservice/UploadFile", opts...)
	if err != nil {
		return nil, err
	}
	x := &fileserviceUploadFileClient{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
}

type Fileservice_UploadFileClient interface {
	Recv() (*FileChunk, error)
	grpc.ClientStream
}

type fileserviceUploadFileClient struct {
	grpc.ClientStream
}

func (x *fileserviceUploadFileClient) Recv() (*FileChunk, error) {
	m := new(FileChunk)
	if err := x.ClientStream.RecvMsg(m); err != nil {
		return nil, err
	}
	return m, nil
}

// FileserviceServer is the server API for Fileservice service.
// All implementations must embed UnimplementedFileserviceServer
// for forward compatibility
type FileserviceServer interface {
	// rpc designed to upload a file from the machine the
	// client is running on to the server.
	DownloadFile(Fileservice_DownloadFileServer) error
	// rpc designed to download a file to the machine the
	// client is running on from the server.
	UploadFile(*FileRequest, Fileservice_UploadFileServer) error
	mustEmbedUnimplementedFileserviceServer()
}

// UnimplementedFileserviceServer must be embedded to have forward compatible implementations.
type UnimplementedFileserviceServer struct {
}

func (UnimplementedFileserviceServer) DownloadFile(Fileservice_DownloadFileServer) error {
	return status.Errorf(codes.Unimplemented, "method DownloadFile not implemented")
}
func (UnimplementedFileserviceServer) UploadFile(*FileRequest, Fileservice_UploadFileServer) error {
	return status.Errorf(codes.Unimplemented, "method UploadFile not implemented")
}
func (UnimplementedFileserviceServer) mustEmbedUnimplementedFileserviceServer() {}

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

func RegisterFileserviceServer(s grpc.ServiceRegistrar, srv FileserviceServer) {
	s.RegisterService(&Fileservice_ServiceDesc, srv)
}

func _Fileservice_DownloadFile_Handler(srv interface{}, stream grpc.ServerStream) error {
	return srv.(FileserviceServer).DownloadFile(&fileserviceDownloadFileServer{stream})
}

type Fileservice_DownloadFileServer interface {
	SendAndClose(*common.StatusMessage) error
	Recv() (*FileChunk, error)
	grpc.ServerStream
}

type fileserviceDownloadFileServer struct {
	grpc.ServerStream
}

func (x *fileserviceDownloadFileServer) SendAndClose(m *common.StatusMessage) error {
	return x.ServerStream.SendMsg(m)
}

func (x *fileserviceDownloadFileServer) Recv() (*FileChunk, error) {
	m := new(FileChunk)
	if err := x.ServerStream.RecvMsg(m); err != nil {
		return nil, err
	}
	return m, nil
}

func _Fileservice_UploadFile_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(FileRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(FileserviceServer).UploadFile(m, &fileserviceUploadFileServer{stream})
}

type Fileservice_UploadFileServer interface {
	Send(*FileChunk) error
	grpc.ServerStream
}

type fileserviceUploadFileServer struct {
	grpc.ServerStream
}

func (x *fileserviceUploadFileServer) Send(m *FileChunk) error {
	return x.ServerStream.SendMsg(m)
}

// Fileservice_ServiceDesc is the grpc.ServiceDesc for Fileservice service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Fileservice_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "filehandler.Fileservice",
	HandlerType: (*FileserviceServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "DownloadFile",
			Handler:       _Fileservice_DownloadFile_Handler,
			ClientStreams: true,
		},
		{
			StreamName:    "UploadFile",
			Handler:       _Fileservice_UploadFile_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "filehandler.proto",
}
