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

package category

import (
	"context"

	"github.com/golang/protobuf/proto"

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

const (
	UpdateEventType = "CategoryUpdate"
)

type Update = CategoryUpdate

type CategoryUpdateHandler func(context.Context, *eventbus.Header, *CategoryUpdate) error

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

func RegisterCategoryUpdateHandler(mux *eventbus.Mux, f CategoryUpdateHandler) {
	mux.RegisterHandler(UpdateEventType, f.Handler())
}

func RegisterUpdateHandler(mux *eventbus.Mux, f CategoryUpdateHandler) {
	RegisterCategoryUpdateHandler(mux, f)
}

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