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

package cloud_vmm

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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7

// SnapshotServiceClient is the client API for SnapshotService 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 SnapshotServiceClient interface {
	// The client is expected to first send a "GuestReady" message, indicating
	// they are available and establishing the connection that vanadium writes
	// requests to the agent on.
	CreateConnection(ctx context.Context, in *GuestReady, opts ...grpc.CallOption) (SnapshotService_CreateConnectionClient, error)
	// Handles the agent's responses to the above requests.
	HandleResponsesFromGuest(ctx context.Context, in *SnapshotResponse, opts ...grpc.CallOption) (*ServerAck, error)
}

type snapshotServiceClient struct {
	cc grpc.ClientConnInterface
}

func NewSnapshotServiceClient(cc grpc.ClientConnInterface) SnapshotServiceClient {
	return &snapshotServiceClient{cc}
}

func (c *snapshotServiceClient) CreateConnection(ctx context.Context, in *GuestReady, opts ...grpc.CallOption) (SnapshotService_CreateConnectionClient, error) {
	stream, err := c.cc.NewStream(ctx, &SnapshotService_ServiceDesc.Streams[0], "/cloud.vmm.SnapshotService/CreateConnection", opts...)
	if err != nil {
		return nil, err
	}
	x := &snapshotServiceCreateConnectionClient{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 SnapshotService_CreateConnectionClient interface {
	Recv() (*GuestMessage, error)
	grpc.ClientStream
}

type snapshotServiceCreateConnectionClient struct {
	grpc.ClientStream
}

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

func (c *snapshotServiceClient) HandleResponsesFromGuest(ctx context.Context, in *SnapshotResponse, opts ...grpc.CallOption) (*ServerAck, error) {
	out := new(ServerAck)
	err := c.cc.Invoke(ctx, "/cloud.vmm.SnapshotService/HandleResponsesFromGuest", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

// SnapshotServiceServer is the server API for SnapshotService service.
// All implementations must embed UnimplementedSnapshotServiceServer
// for forward compatibility
type SnapshotServiceServer interface {
	// The client is expected to first send a "GuestReady" message, indicating
	// they are available and establishing the connection that vanadium writes
	// requests to the agent on.
	CreateConnection(*GuestReady, SnapshotService_CreateConnectionServer) error
	// Handles the agent's responses to the above requests.
	HandleResponsesFromGuest(context.Context, *SnapshotResponse) (*ServerAck, error)
	mustEmbedUnimplementedSnapshotServiceServer()
}

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

func (UnimplementedSnapshotServiceServer) CreateConnection(*GuestReady, SnapshotService_CreateConnectionServer) error {
	return status.Errorf(codes.Unimplemented, "method CreateConnection not implemented")
}
func (UnimplementedSnapshotServiceServer) HandleResponsesFromGuest(context.Context, *SnapshotResponse) (*ServerAck, error) {
	return nil, status.Errorf(codes.Unimplemented, "method HandleResponsesFromGuest not implemented")
}
func (UnimplementedSnapshotServiceServer) mustEmbedUnimplementedSnapshotServiceServer() {}

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

func RegisterSnapshotServiceServer(s grpc.ServiceRegistrar, srv SnapshotServiceServer) {
	s.RegisterService(&SnapshotService_ServiceDesc, srv)
}

func _SnapshotService_CreateConnection_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(GuestReady)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(SnapshotServiceServer).CreateConnection(m, &snapshotServiceCreateConnectionServer{stream})
}

type SnapshotService_CreateConnectionServer interface {
	Send(*GuestMessage) error
	grpc.ServerStream
}

type snapshotServiceCreateConnectionServer struct {
	grpc.ServerStream
}

func (x *snapshotServiceCreateConnectionServer) Send(m *GuestMessage) error {
	return x.ServerStream.SendMsg(m)
}

func _SnapshotService_HandleResponsesFromGuest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(SnapshotResponse)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(SnapshotServiceServer).HandleResponsesFromGuest(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/cloud.vmm.SnapshotService/HandleResponsesFromGuest",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(SnapshotServiceServer).HandleResponsesFromGuest(ctx, req.(*SnapshotResponse))
	}
	return interceptor(ctx, in, info, handler)
}

// SnapshotService_ServiceDesc is the grpc.ServiceDesc for SnapshotService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var SnapshotService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "cloud.vmm.SnapshotService",
	HandlerType: (*SnapshotServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "HandleResponsesFromGuest",
			Handler:    _SnapshotService_HandleResponsesFromGuest_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "CreateConnection",
			Handler:       _SnapshotService_CreateConnection_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "snapshot_service.proto",
}
