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

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

type TTRPCStreamingService interface {
	Stream(context.Context, TTRPCStreaming_StreamServer) error
}

type TTRPCStreaming_StreamServer interface {
	Send(*anypb.Any) error
	Recv() (*anypb.Any, error)
	ttrpc.StreamServer
}

type ttrpcstreamingStreamServer struct {
	ttrpc.StreamServer
}

func (x *ttrpcstreamingStreamServer) Send(m *anypb.Any) error {
	return x.StreamServer.SendMsg(m)
}

func (x *ttrpcstreamingStreamServer) Recv() (*anypb.Any, error) {
	m := new(anypb.Any)
	if err := x.StreamServer.RecvMsg(m); err != nil {
		return nil, err
	}
	return m, nil
}

func RegisterTTRPCStreamingService(srv *ttrpc.Server, svc TTRPCStreamingService) {
	srv.RegisterService("containerd.services.streaming.v1.Streaming", &ttrpc.ServiceDesc{
		Streams: map[string]ttrpc.Stream{
			"Stream": {
				Handler: func(ctx context.Context, stream ttrpc.StreamServer) (interface{}, error) {
					return nil, svc.Stream(ctx, &ttrpcstreamingStreamServer{stream})
				},
				StreamingClient: true,
				StreamingServer: true,
			},
		},
	})
}

type TTRPCStreamingClient interface {
	Stream(context.Context) (TTRPCStreaming_StreamClient, error)
}

type ttrpcstreamingClient struct {
	client *ttrpc.Client
}

func NewTTRPCStreamingClient(client *ttrpc.Client) TTRPCStreamingClient {
	return &ttrpcstreamingClient{
		client: client,
	}
}

func (c *ttrpcstreamingClient) Stream(ctx context.Context) (TTRPCStreaming_StreamClient, error) {
	stream, err := c.client.NewStream(ctx, &ttrpc.StreamDesc{
		StreamingClient: true,
		StreamingServer: true,
	}, "containerd.services.streaming.v1.Streaming", "Stream", nil)
	if err != nil {
		return nil, err
	}
	x := &ttrpcstreamingStreamClient{stream}
	return x, nil
}

type TTRPCStreaming_StreamClient interface {
	Send(*anypb.Any) error
	Recv() (*anypb.Any, error)
	ttrpc.ClientStream
}

type ttrpcstreamingStreamClient struct {
	ttrpc.ClientStream
}

func (x *ttrpcstreamingStreamClient) Send(m *anypb.Any) error {
	return x.ClientStream.SendMsg(m)
}

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