// Code generated by protoc-gen-psrpc v0.7.0, DO NOT EDIT.
// source: rpc/whip_signal.proto

package rpc

import (
	"context"

	"github.com/livekit/psrpc"
	"github.com/livekit/psrpc/pkg/client"
	"github.com/livekit/psrpc/pkg/info"
	"github.com/livekit/psrpc/pkg/rand"
	"github.com/livekit/psrpc/pkg/server"
	"github.com/livekit/psrpc/version"
)
import google_protobuf "google.golang.org/protobuf/types/known/emptypb"

var _ = version.PsrpcVersion_0_7

// =====================
// WHIP Client Interface
// =====================

type WHIPClient[TopicTopicType ~string] interface {
	Create(ctx context.Context, topic TopicTopicType, req *WHIPCreateRequest, opts ...psrpc.RequestOption) (*WHIPCreateResponse, error)

	// Close immediately, without waiting for pending RPCs
	Close()
}

// =========================
// WHIP ServerImpl Interface
// =========================

type WHIPServerImpl interface {
	Create(context.Context, *WHIPCreateRequest) (*WHIPCreateResponse, error)
}

// =====================
// WHIP Server Interface
// =====================

type WHIPServer[TopicTopicType ~string] interface {
	RegisterCreateTopic(topic TopicTopicType) error
	DeregisterCreateTopic(topic TopicTopicType)
	RegisterAllCommonTopics(topic TopicTopicType) error
	DeregisterAllCommonTopics(topic TopicTopicType)

	// Close and wait for pending RPCs to complete
	Shutdown()

	// Close immediately, without waiting for pending RPCs
	Kill()
}

// ===========
// WHIP Client
// ===========

type wHIPClient[TopicTopicType ~string] struct {
	client *client.RPCClient
}

// NewWHIPClient creates a psrpc client that implements the WHIPClient interface.
func NewWHIPClient[TopicTopicType ~string](bus psrpc.MessageBus, opts ...psrpc.ClientOption) (WHIPClient[TopicTopicType], error) {
	sd := &info.ServiceDefinition{
		Name: "WHIP",
		ID:   rand.NewClientID(),
	}

	sd.RegisterMethod("Create", false, false, true, true)

	rpcClient, err := client.NewRPCClient(sd, bus, opts...)
	if err != nil {
		return nil, err
	}

	return &wHIPClient[TopicTopicType]{
		client: rpcClient,
	}, nil
}

func (c *wHIPClient[TopicTopicType]) Create(ctx context.Context, topic TopicTopicType, req *WHIPCreateRequest, opts ...psrpc.RequestOption) (*WHIPCreateResponse, error) {
	return client.RequestSingle[*WHIPCreateResponse](ctx, c.client, "Create", []string{string(topic)}, req, opts...)
}

func (s *wHIPClient[TopicTopicType]) Close() {
	s.client.Close()
}

// ===========
// WHIP Server
// ===========

type wHIPServer[TopicTopicType ~string] struct {
	svc WHIPServerImpl
	rpc *server.RPCServer
}

// NewWHIPServer builds a RPCServer that will route requests
// to the corresponding method in the provided svc implementation.
func NewWHIPServer[TopicTopicType ~string](svc WHIPServerImpl, bus psrpc.MessageBus, opts ...psrpc.ServerOption) (WHIPServer[TopicTopicType], error) {
	sd := &info.ServiceDefinition{
		Name: "WHIP",
		ID:   rand.NewServerID(),
	}

	s := server.NewRPCServer(sd, bus, opts...)

	sd.RegisterMethod("Create", false, false, true, true)
	return &wHIPServer[TopicTopicType]{
		svc: svc,
		rpc: s,
	}, nil
}

func (s *wHIPServer[TopicTopicType]) RegisterCreateTopic(topic TopicTopicType) error {
	return server.RegisterHandler(s.rpc, "Create", []string{string(topic)}, s.svc.Create, nil)
}

func (s *wHIPServer[TopicTopicType]) DeregisterCreateTopic(topic TopicTopicType) {
	s.rpc.DeregisterHandler("Create", []string{string(topic)})
}

func (s *wHIPServer[TopicTopicType]) allCommonTopicRegisterers() server.RegistererSlice {
	return server.RegistererSlice{
		server.NewRegisterer(s.RegisterCreateTopic, s.DeregisterCreateTopic),
	}
}

func (s *wHIPServer[TopicTopicType]) RegisterAllCommonTopics(topic TopicTopicType) error {
	return s.allCommonTopicRegisterers().Register(topic)
}

func (s *wHIPServer[TopicTopicType]) DeregisterAllCommonTopics(topic TopicTopicType) {
	s.allCommonTopicRegisterers().Deregister(topic)
}

func (s *wHIPServer[TopicTopicType]) Shutdown() {
	s.rpc.Close(false)
}

func (s *wHIPServer[TopicTopicType]) Kill() {
	s.rpc.Close(true)
}

// =========================
// WHIP Unimplemented Server
// =========================

type UnimplementedWHIPServer struct{}

func (UnimplementedWHIPServer) Create(context.Context, *WHIPCreateRequest) (*WHIPCreateResponse, error) {
	return nil, psrpc.ErrUnimplemented
}

// ================================
// WHIPParticipant Client Interface
// ================================

type WHIPParticipantClient[TopicTopicType ~string] interface {
	ICETrickle(ctx context.Context, topic TopicTopicType, req *WHIPParticipantICETrickleRequest, opts ...psrpc.RequestOption) (*google_protobuf.Empty, error)

	ICERestart(ctx context.Context, topic TopicTopicType, req *WHIPParticipantICERestartRequest, opts ...psrpc.RequestOption) (*WHIPParticipantICERestartResponse, error)

	DeleteSession(ctx context.Context, topic TopicTopicType, req *WHIPParticipantDeleteSessionRequest, opts ...psrpc.RequestOption) (*google_protobuf.Empty, error)

	// Close immediately, without waiting for pending RPCs
	Close()
}

// ====================================
// WHIPParticipant ServerImpl Interface
// ====================================

type WHIPParticipantServerImpl interface {
	ICETrickle(context.Context, *WHIPParticipantICETrickleRequest) (*google_protobuf.Empty, error)

	ICERestart(context.Context, *WHIPParticipantICERestartRequest) (*WHIPParticipantICERestartResponse, error)

	DeleteSession(context.Context, *WHIPParticipantDeleteSessionRequest) (*google_protobuf.Empty, error)
}

// ================================
// WHIPParticipant Server Interface
// ================================

type WHIPParticipantServer[TopicTopicType ~string] interface {
	RegisterICETrickleTopic(topic TopicTopicType) error
	DeregisterICETrickleTopic(topic TopicTopicType)
	RegisterICERestartTopic(topic TopicTopicType) error
	DeregisterICERestartTopic(topic TopicTopicType)
	RegisterDeleteSessionTopic(topic TopicTopicType) error
	DeregisterDeleteSessionTopic(topic TopicTopicType)
	RegisterAllCommonTopics(topic TopicTopicType) error
	DeregisterAllCommonTopics(topic TopicTopicType)

	// Close and wait for pending RPCs to complete
	Shutdown()

	// Close immediately, without waiting for pending RPCs
	Kill()
}

// ======================
// WHIPParticipant Client
// ======================

type wHIPParticipantClient[TopicTopicType ~string] struct {
	client *client.RPCClient
}

// NewWHIPParticipantClient creates a psrpc client that implements the WHIPParticipantClient interface.
func NewWHIPParticipantClient[TopicTopicType ~string](bus psrpc.MessageBus, opts ...psrpc.ClientOption) (WHIPParticipantClient[TopicTopicType], error) {
	sd := &info.ServiceDefinition{
		Name: "WHIPParticipant",
		ID:   rand.NewClientID(),
	}

	sd.RegisterMethod("ICETrickle", false, false, true, true)
	sd.RegisterMethod("ICERestart", false, false, true, true)
	sd.RegisterMethod("DeleteSession", false, false, true, true)

	rpcClient, err := client.NewRPCClient(sd, bus, opts...)
	if err != nil {
		return nil, err
	}

	return &wHIPParticipantClient[TopicTopicType]{
		client: rpcClient,
	}, nil
}

func (c *wHIPParticipantClient[TopicTopicType]) ICETrickle(ctx context.Context, topic TopicTopicType, req *WHIPParticipantICETrickleRequest, opts ...psrpc.RequestOption) (*google_protobuf.Empty, error) {
	return client.RequestSingle[*google_protobuf.Empty](ctx, c.client, "ICETrickle", []string{string(topic)}, req, opts...)
}

func (c *wHIPParticipantClient[TopicTopicType]) ICERestart(ctx context.Context, topic TopicTopicType, req *WHIPParticipantICERestartRequest, opts ...psrpc.RequestOption) (*WHIPParticipantICERestartResponse, error) {
	return client.RequestSingle[*WHIPParticipantICERestartResponse](ctx, c.client, "ICERestart", []string{string(topic)}, req, opts...)
}

func (c *wHIPParticipantClient[TopicTopicType]) DeleteSession(ctx context.Context, topic TopicTopicType, req *WHIPParticipantDeleteSessionRequest, opts ...psrpc.RequestOption) (*google_protobuf.Empty, error) {
	return client.RequestSingle[*google_protobuf.Empty](ctx, c.client, "DeleteSession", []string{string(topic)}, req, opts...)
}

func (s *wHIPParticipantClient[TopicTopicType]) Close() {
	s.client.Close()
}

// ======================
// WHIPParticipant Server
// ======================

type wHIPParticipantServer[TopicTopicType ~string] struct {
	svc WHIPParticipantServerImpl
	rpc *server.RPCServer
}

// NewWHIPParticipantServer builds a RPCServer that will route requests
// to the corresponding method in the provided svc implementation.
func NewWHIPParticipantServer[TopicTopicType ~string](svc WHIPParticipantServerImpl, bus psrpc.MessageBus, opts ...psrpc.ServerOption) (WHIPParticipantServer[TopicTopicType], error) {
	sd := &info.ServiceDefinition{
		Name: "WHIPParticipant",
		ID:   rand.NewServerID(),
	}

	s := server.NewRPCServer(sd, bus, opts...)

	sd.RegisterMethod("ICETrickle", false, false, true, true)
	sd.RegisterMethod("ICERestart", false, false, true, true)
	sd.RegisterMethod("DeleteSession", false, false, true, true)
	return &wHIPParticipantServer[TopicTopicType]{
		svc: svc,
		rpc: s,
	}, nil
}

func (s *wHIPParticipantServer[TopicTopicType]) RegisterICETrickleTopic(topic TopicTopicType) error {
	return server.RegisterHandler(s.rpc, "ICETrickle", []string{string(topic)}, s.svc.ICETrickle, nil)
}

func (s *wHIPParticipantServer[TopicTopicType]) DeregisterICETrickleTopic(topic TopicTopicType) {
	s.rpc.DeregisterHandler("ICETrickle", []string{string(topic)})
}

func (s *wHIPParticipantServer[TopicTopicType]) RegisterICERestartTopic(topic TopicTopicType) error {
	return server.RegisterHandler(s.rpc, "ICERestart", []string{string(topic)}, s.svc.ICERestart, nil)
}

func (s *wHIPParticipantServer[TopicTopicType]) DeregisterICERestartTopic(topic TopicTopicType) {
	s.rpc.DeregisterHandler("ICERestart", []string{string(topic)})
}

func (s *wHIPParticipantServer[TopicTopicType]) RegisterDeleteSessionTopic(topic TopicTopicType) error {
	return server.RegisterHandler(s.rpc, "DeleteSession", []string{string(topic)}, s.svc.DeleteSession, nil)
}

func (s *wHIPParticipantServer[TopicTopicType]) DeregisterDeleteSessionTopic(topic TopicTopicType) {
	s.rpc.DeregisterHandler("DeleteSession", []string{string(topic)})
}

func (s *wHIPParticipantServer[TopicTopicType]) allCommonTopicRegisterers() server.RegistererSlice {
	return server.RegistererSlice{
		server.NewRegisterer(s.RegisterICETrickleTopic, s.DeregisterICETrickleTopic),
		server.NewRegisterer(s.RegisterICERestartTopic, s.DeregisterICERestartTopic),
		server.NewRegisterer(s.RegisterDeleteSessionTopic, s.DeregisterDeleteSessionTopic),
	}
}

func (s *wHIPParticipantServer[TopicTopicType]) RegisterAllCommonTopics(topic TopicTopicType) error {
	return s.allCommonTopicRegisterers().Register(topic)
}

func (s *wHIPParticipantServer[TopicTopicType]) DeregisterAllCommonTopics(topic TopicTopicType) {
	s.allCommonTopicRegisterers().Deregister(topic)
}

func (s *wHIPParticipantServer[TopicTopicType]) Shutdown() {
	s.rpc.Close(false)
}

func (s *wHIPParticipantServer[TopicTopicType]) Kill() {
	s.rpc.Close(true)
}

// ====================================
// WHIPParticipant Unimplemented Server
// ====================================

type UnimplementedWHIPParticipantServer struct{}

func (UnimplementedWHIPParticipantServer) ICETrickle(context.Context, *WHIPParticipantICETrickleRequest) (*google_protobuf.Empty, error) {
	return nil, psrpc.ErrUnimplemented
}

func (UnimplementedWHIPParticipantServer) ICERestart(context.Context, *WHIPParticipantICERestartRequest) (*WHIPParticipantICERestartResponse, error) {
	return nil, psrpc.ErrUnimplemented
}

func (UnimplementedWHIPParticipantServer) DeleteSession(context.Context, *WHIPParticipantDeleteSessionRequest) (*google_protobuf.Empty, error) {
	return nil, psrpc.ErrUnimplemented
}

var psrpcFileDescriptor10 = []byte{
	// 726 bytes of a gzipped FileDescriptorProto
	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0x5f, 0x4f, 0x1b, 0x39,
	0x10, 0xd7, 0x26, 0x01, 0x91, 0x09, 0xe1, 0xc0, 0x77, 0x40, 0x6e, 0x23, 0xc4, 0x92, 0x3b, 0x4e,
	0x79, 0x38, 0x6d, 0x74, 0x41, 0xba, 0x22, 0x1e, 0x4b, 0x53, 0x35, 0x52, 0x55, 0xa1, 0x0d, 0x6a,
	0xa5, 0x3e, 0x74, 0xb5, 0xf1, 0x3a, 0xc1, 0xca, 0xee, 0xda, 0xb5, 0x9d, 0xa0, 0xa8, 0x9f, 0x80,
	0xef, 0xd2, 0x27, 0xaa, 0xf6, 0xbb, 0xf4, 0xa9, 0x5f, 0xa5, 0x5a, 0x7b, 0x13, 0x12, 0x12, 0xfe,
	0xa8, 0x2f, 0xbc, 0xd9, 0x3f, 0x8f, 0x67, 0x7e, 0xf3, 0x9b, 0x19, 0x1b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