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

package channel_ad_free_benefit

import (
	"context"

	"github.com/golang/protobuf/proto"

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

const (
	UpdateEventType = "ChannelAdFreeBenefitUpdate"
)

type Update = ChannelAdFreeBenefitUpdate

type ChannelAdFreeBenefitUpdateHandler func(context.Context, *eventbus.Header, *ChannelAdFreeBenefitUpdate) error

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

func RegisterChannelAdFreeBenefitUpdateHandler(mux *eventbus.Mux, f ChannelAdFreeBenefitUpdateHandler) {
	mux.RegisterHandler(UpdateEventType, f.Handler())
}

func RegisterUpdateHandler(mux *eventbus.Mux, f ChannelAdFreeBenefitUpdateHandler) {
	RegisterChannelAdFreeBenefitUpdateHandler(mux, f)
}

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