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

package clock

import (
	"context"

	"github.com/golang/protobuf/proto"

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

const (
	UpdateEventType = "ClockUpdate"
)

type Update = ClockUpdate

type ClockUpdateHandler func(context.Context, *eventbus.Header, *ClockUpdate) error

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

func RegisterClockUpdateHandler(mux *eventbus.Mux, f ClockUpdateHandler) {
	mux.RegisterHandler(UpdateEventType, f.Handler())
}

func RegisterUpdateHandler(mux *eventbus.Mux, f ClockUpdateHandler) {
	RegisterClockUpdateHandler(mux, f)
}

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