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

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

type TTRPCMountsService interface {
	Activate(context.Context, *ActivateRequest) (*ActivateResponse, error)
	Deactivate(context.Context, *DeactivateRequest) (*emptypb.Empty, error)
	Info(context.Context, *InfoRequest) (*InfoResponse, error)
	Update(context.Context, *UpdateRequest) (*UpdateResponse, error)
	List(context.Context, *ListRequest, TTRPCMounts_ListServer) error
}

type TTRPCMounts_ListServer interface {
	Send(*ListMessage) error
	ttrpc.StreamServer
}

type ttrpcmountsListServer struct {
	ttrpc.StreamServer
}

func (x *ttrpcmountsListServer) Send(m *ListMessage) error {
	return x.StreamServer.SendMsg(m)
}

func RegisterTTRPCMountsService(srv *ttrpc.Server, svc TTRPCMountsService) {
	srv.RegisterService("containerd.services.mounts.v1.Mounts", &ttrpc.ServiceDesc{
		Methods: map[string]ttrpc.Method{
			"Activate": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
				var req ActivateRequest
				if err := unmarshal(&req); err != nil {
					return nil, err
				}
				return svc.Activate(ctx, &req)
			},
			"Deactivate": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
				var req DeactivateRequest
				if err := unmarshal(&req); err != nil {
					return nil, err
				}
				return svc.Deactivate(ctx, &req)
			},
			"Info": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
				var req InfoRequest
				if err := unmarshal(&req); err != nil {
					return nil, err
				}
				return svc.Info(ctx, &req)
			},
			"Update": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
				var req UpdateRequest
				if err := unmarshal(&req); err != nil {
					return nil, err
				}
				return svc.Update(ctx, &req)
			},
		},
		Streams: map[string]ttrpc.Stream{
			"List": {
				Handler: func(ctx context.Context, stream ttrpc.StreamServer) (interface{}, error) {
					m := new(ListRequest)
					if err := stream.RecvMsg(m); err != nil {
						return nil, err
					}
					return nil, svc.List(ctx, m, &ttrpcmountsListServer{stream})
				},
				StreamingClient: false,
				StreamingServer: true,
			},
		},
	})
}

type TTRPCMountsClient interface {
	Activate(context.Context, *ActivateRequest) (*ActivateResponse, error)
	Deactivate(context.Context, *DeactivateRequest) (*emptypb.Empty, error)
	Info(context.Context, *InfoRequest) (*InfoResponse, error)
	Update(context.Context, *UpdateRequest) (*UpdateResponse, error)
	List(context.Context, *ListRequest) (TTRPCMounts_ListClient, error)
}

type ttrpcmountsClient struct {
	client *ttrpc.Client
}

func NewTTRPCMountsClient(client *ttrpc.Client) TTRPCMountsClient {
	return &ttrpcmountsClient{
		client: client,
	}
}

func (c *ttrpcmountsClient) Activate(ctx context.Context, req *ActivateRequest) (*ActivateResponse, error) {
	var resp ActivateResponse
	if err := c.client.Call(ctx, "containerd.services.mounts.v1.Mounts", "Activate", req, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}

func (c *ttrpcmountsClient) Deactivate(ctx context.Context, req *DeactivateRequest) (*emptypb.Empty, error) {
	var resp emptypb.Empty
	if err := c.client.Call(ctx, "containerd.services.mounts.v1.Mounts", "Deactivate", req, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}

func (c *ttrpcmountsClient) Info(ctx context.Context, req *InfoRequest) (*InfoResponse, error) {
	var resp InfoResponse
	if err := c.client.Call(ctx, "containerd.services.mounts.v1.Mounts", "Info", req, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}

func (c *ttrpcmountsClient) Update(ctx context.Context, req *UpdateRequest) (*UpdateResponse, error) {
	var resp UpdateResponse
	if err := c.client.Call(ctx, "containerd.services.mounts.v1.Mounts", "Update", req, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}

func (c *ttrpcmountsClient) List(ctx context.Context, req *ListRequest) (TTRPCMounts_ListClient, error) {
	stream, err := c.client.NewStream(ctx, &ttrpc.StreamDesc{
		StreamingClient: false,
		StreamingServer: true,
	}, "containerd.services.mounts.v1.Mounts", "List", req)
	if err != nil {
		return nil, err
	}
	x := &ttrpcmountsListClient{stream}
	return x, nil
}

type TTRPCMounts_ListClient interface {
	Recv() (*ListMessage, error)
	ttrpc.ClientStream
}

type ttrpcmountsListClient struct {
	ttrpc.ClientStream
}

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