mirror of
https://github.com/xaionaro-go/streamctl.git
synced 2025-12-24 12:27:57 +08:00
Continue the implementation of trigger rules (ex scene rules)
This commit is contained in:
27
pkg/streamd/config/event/eventquery/event_query.go
Normal file
27
pkg/streamd/config/event/eventquery/event_query.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package eventquery
|
||||
|
||||
import (
|
||||
"github.com/xaionaro-go/streamctl/pkg/serializable"
|
||||
"github.com/xaionaro-go/streamctl/pkg/streamd/config/event"
|
||||
)
|
||||
|
||||
func init() {
|
||||
serializable.RegisterType[EventType[event.WindowFocusChange]]()
|
||||
}
|
||||
|
||||
type EventQuery interface {
|
||||
Match(event.Event) bool
|
||||
}
|
||||
|
||||
type Event serializable.Serializable[event.Event]
|
||||
|
||||
func (ev Event) Match(cmp event.Event) bool {
|
||||
return ev.Value == cmp
|
||||
}
|
||||
|
||||
type EventType[T event.Event] struct{}
|
||||
|
||||
func (EventType[T]) Match(ev event.Event) bool {
|
||||
_, ok := ev.(T)
|
||||
return ok
|
||||
}
|
||||
Reference in New Issue
Block a user