// NOTE this is a generated file! do not edit!

package channel

import (
	"context"

	"github.com/golang/protobuf/proto"

	eventbus "code.justin.tv/eventbus/client"
)

const (
	UpdateEventType = "ChannelUpdate"
)

type Update = ChannelUpdate

type ChannelUpdateHandler func(context.Context, *eventbus.Header, *ChannelUpdate) error

func (h ChannelUpdateHandler) Handler() eventbus.Handler {
	return func(ctx context.Context, message eventbus.RawMessage) error {
		dst := &ChannelUpdate{}
		err := proto.Unmarshal(message.Payload, dst)
		if err != nil {
			return err
		}
		return h(ctx, message.Header, dst)
	}
}

func RegisterChannelUpdateHandler(mux *eventbus.Mux, f ChannelUpdateHandler) {
	mux.RegisterHandler(UpdateEventType, f.Handler())
}

func RegisterUpdateHandler(mux *eventbus.Mux, f ChannelUpdateHandler) {
	RegisterChannelUpdateHandler(mux, f)
}

func (*ChannelUpdate) EventBusName() string {
	return UpdateEventType
}
