// Code generated by protoc-gen-go-ttrpc. DO NOT EDIT.
// source: github.com/containerd/containerd/api/services/snapshots/v1/snapshots.proto
package snapshots

import (
	context "context"
	ttrpc "github.com/containerd/ttrpc"
	emptypb "google.golang.org/protobuf/types/known/emptypb"
)

type TTRPCSnapshotsService interface {
	Prepare(context.Context, *PrepareSnapshotRequest) (*PrepareSnapshotResponse, error)
	View(context.Context, *ViewSnapshotRequest) (*ViewSnapshotResponse, error)
	Mounts(context.Context, *MountsRequest) (*MountsResponse, error)
	Commit(context.Context, *CommitSnapshotRequest) (*emptypb.Empty, error)
	Remove(context.Context, *RemoveSnapshotRequest) (*emptypb.Empty, error)
	Stat(context.Context, *StatSnapshotRequest) (*StatSnapshotResponse, error)
	Update(context.Context, *UpdateSnapshotRequest) (*UpdateSnapshotResponse, error)
	List(context.Context, *ListSnapshotsRequest, TTRPCSnapshots_ListServer) error
	Usage(context.Context, *UsageRequest) (*UsageResponse, error)
	Cleanup(context.Context, *CleanupRequest) (*emptypb.Empty, error)
}

type TTRPCSnapshots_ListServer interface {
	Send(*ListSnapshotsResponse) error
	ttrpc.StreamServer
}

type ttrpcsnapshotsListServer struct {
	ttrpc.StreamServer
}

func (x *ttrpcsnapshotsListServer) Send(m *ListSnapshotsResponse) error {
	return x.StreamServer.SendMsg(m)
}

func RegisterTTRPCSnapshotsService(srv *ttrpc.Server, svc TTRPCSnapshotsService) {
	srv.RegisterService("containerd.services.snapshots.v1.Snapshots", &ttrpc.ServiceDesc{
		Methods: map[string]ttrpc.Method{
			"Prepare": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
				var req PrepareSnapshotRequest
				if err := unmarshal(&req); err != nil {
					return nil, err
				}
				return svc.Prepare(ctx, &req)
			},
			"View": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
				var req ViewSnapshotRequest
				if err := unmarshal(&req); err != nil {
					return nil, err
				}
				return svc.View(ctx, &req)
			},
			"Mounts": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
				var req MountsRequest
				if err := unmarshal(&req); err != nil {
					return nil, err
				}
				return svc.Mounts(ctx, &req)
			},
			"Commit": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
				var req CommitSnapshotRequest
				if err := unmarshal(&req); err != nil {
					return nil, err
				}
				return svc.Commit(ctx, &req)
			},
			"Remove": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
				var req RemoveSnapshotRequest
				if err := unmarshal(&req); err != nil {
					return nil, err
				}
				return svc.Remove(ctx, &req)
			},
			"Stat": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
				var req StatSnapshotRequest
				if err := unmarshal(&req); err != nil {
					return nil, err
				}
				return svc.Stat(ctx, &req)
			},
			"Update": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
				var req UpdateSnapshotRequest
				if err := unmarshal(&req); err != nil {
					return nil, err
				}
				return svc.Update(ctx, &req)
			},
			"Usage": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
				var req UsageRequest
				if err := unmarshal(&req); err != nil {
					return nil, err
				}
				return svc.Usage(ctx, &req)
			},
			"Cleanup": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
				var req CleanupRequest
				if err := unmarshal(&req); err != nil {
					return nil, err
				}
				return svc.Cleanup(ctx, &req)
			},
		},
		Streams: map[string]ttrpc.Stream{
			"List": {
				Handler: func(ctx context.Context, stream ttrpc.StreamServer) (interface{}, error) {
					m := new(ListSnapshotsRequest)
					if err := stream.RecvMsg(m); err != nil {
						return nil, err
					}
					return nil, svc.List(ctx, m, &ttrpcsnapshotsListServer{stream})
				},
				StreamingClient: false,
				StreamingServer: true,
			},
		},
	})
}

type TTRPCSnapshotsClient interface {
	Prepare(context.Context, *PrepareSnapshotRequest) (*PrepareSnapshotResponse, error)
	View(context.Context, *ViewSnapshotRequest) (*ViewSnapshotResponse, error)
	Mounts(context.Context, *MountsRequest) (*MountsResponse, error)
	Commit(context.Context, *CommitSnapshotRequest) (*emptypb.Empty, error)
	Remove(context.Context, *RemoveSnapshotRequest) (*emptypb.Empty, error)
	Stat(context.Context, *StatSnapshotRequest) (*StatSnapshotResponse, error)
	Update(context.Context, *UpdateSnapshotRequest) (*UpdateSnapshotResponse, error)
	List(context.Context, *ListSnapshotsRequest) (TTRPCSnapshots_ListClient, error)
	Usage(context.Context, *UsageRequest) (*UsageResponse, error)
	Cleanup(context.Context, *CleanupRequest) (*emptypb.Empty, error)
}

type ttrpcsnapshotsClient struct {
	client *ttrpc.Client
}

func NewTTRPCSnapshotsClient(client *ttrpc.Client) TTRPCSnapshotsClient {
	return &ttrpcsnapshotsClient{
		client: client,
	}
}

func (c *ttrpcsnapshotsClient) Prepare(ctx context.Context, req *PrepareSnapshotRequest) (*PrepareSnapshotResponse, error) {
	var resp PrepareSnapshotResponse
	if err := c.client.Call(ctx, "containerd.services.snapshots.v1.Snapshots", "Prepare", req, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}

func (c *ttrpcsnapshotsClient) View(ctx context.Context, req *ViewSnapshotRequest) (*ViewSnapshotResponse, error) {
	var resp ViewSnapshotResponse
	if err := c.client.Call(ctx, "containerd.services.snapshots.v1.Snapshots", "View", req, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}

func (c *ttrpcsnapshotsClient) Mounts(ctx context.Context, req *MountsRequest) (*MountsResponse, error) {
	var resp MountsResponse
	if err := c.client.Call(ctx, "containerd.services.snapshots.v1.Snapshots", "Mounts", req, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}

func (c *ttrpcsnapshotsClient) Commit(ctx context.Context, req *CommitSnapshotRequest) (*emptypb.Empty, error) {
	var resp emptypb.Empty
	if err := c.client.Call(ctx, "containerd.services.snapshots.v1.Snapshots", "Commit", req, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}

func (c *ttrpcsnapshotsClient) Remove(ctx context.Context, req *RemoveSnapshotRequest) (*emptypb.Empty, error) {
	var resp emptypb.Empty
	if err := c.client.Call(ctx, "containerd.services.snapshots.v1.Snapshots", "Remove", req, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}

func (c *ttrpcsnapshotsClient) Stat(ctx context.Context, req *StatSnapshotRequest) (*StatSnapshotResponse, error) {
	var resp StatSnapshotResponse
	if err := c.client.Call(ctx, "containerd.services.snapshots.v1.Snapshots", "Stat", req, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}

func (c *ttrpcsnapshotsClient) Update(ctx context.Context, req *UpdateSnapshotRequest) (*UpdateSnapshotResponse, error) {
	var resp UpdateSnapshotResponse
	if err := c.client.Call(ctx, "containerd.services.snapshots.v1.Snapshots", "Update", req, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}

func (c *ttrpcsnapshotsClient) List(ctx context.Context, req *ListSnapshotsRequest) (TTRPCSnapshots_ListClient, error) {
	stream, err := c.client.NewStream(ctx, &ttrpc.StreamDesc{
		StreamingClient: false,
		StreamingServer: true,
	}, "containerd.services.snapshots.v1.Snapshots", "List", req)
	if err != nil {
		return nil, err
	}
	x := &ttrpcsnapshotsListClient{stream}
	return x, nil
}

type TTRPCSnapshots_ListClient interface {
	Recv() (*ListSnapshotsResponse, error)
	ttrpc.ClientStream
}

type ttrpcsnapshotsListClient struct {
	ttrpc.ClientStream
}

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

func (c *ttrpcsnapshotsClient) Usage(ctx context.Context, req *UsageRequest) (*UsageResponse, error) {
	var resp UsageResponse
	if err := c.client.Call(ctx, "containerd.services.snapshots.v1.Snapshots", "Usage", req, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}

func (c *ttrpcsnapshotsClient) Cleanup(ctx context.Context, req *CleanupRequest) (*emptypb.Empty, error) {
	var resp emptypb.Empty
	if err := c.client.Call(ctx, "containerd.services.snapshots.v1.Snapshots", "Cleanup", req, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}
