76 lines
1.7 KiB
Go
76 lines
1.7 KiB
Go
package niri
|
|
|
|
import (
|
|
json "encoding/json"
|
|
"errors"
|
|
)
|
|
|
|
type ModeToSet struct {
|
|
automatic Option[bool]
|
|
specific Option[ConfiguredMode]
|
|
}
|
|
|
|
func OutputActionModeAutomatic() ModeToSet {
|
|
return ModeToSet{automatic: OptionOf(true)}
|
|
}
|
|
|
|
func OutputActionModeSpecific(mode ConfiguredMode) ModeToSet {
|
|
return ModeToSet{specific: OptionOf(mode)}
|
|
}
|
|
|
|
func (m ModeToSet) MarshalJSON() ([]byte, error) {
|
|
if m.automatic != nil {
|
|
return json.Marshal("Automatic")
|
|
} else if m.specific != nil {
|
|
return json.Marshal(map[string]any{"Specific": m.specific})
|
|
}
|
|
|
|
return nil, errors.New("ModeToSet.MarshalJson()")
|
|
}
|
|
|
|
type ScaleToSet struct {
|
|
automatic Option[bool]
|
|
specific Option[float64]
|
|
}
|
|
|
|
func OutputActionScaleAutomatic() ScaleToSet {
|
|
return ScaleToSet{automatic: OptionOf(true)}
|
|
}
|
|
|
|
func OutputActionScaleSpecific(scale float64) ScaleToSet {
|
|
return ScaleToSet{specific: OptionOf(scale)}
|
|
}
|
|
|
|
func (m ScaleToSet) MarshalJSON() ([]byte, error) {
|
|
if m.automatic != nil {
|
|
return json.Marshal("Automatic")
|
|
} else if m.specific != nil {
|
|
return json.Marshal(map[string]any{"Specific": m.specific})
|
|
}
|
|
|
|
return nil, errors.New("ScaleToSet.MarshalJson()")
|
|
}
|
|
|
|
type PositionToSet struct {
|
|
automatic Option[bool]
|
|
specific Option[ConfiguredPosition]
|
|
}
|
|
|
|
func OutputActionPositionAutomatic() *PositionToSet {
|
|
return &PositionToSet{automatic: OptionOf(true)}
|
|
}
|
|
|
|
func OutputActionPositionSpecific(position ConfiguredPosition) *PositionToSet {
|
|
return &PositionToSet{specific: OptionOf(position)}
|
|
}
|
|
|
|
func (m PositionToSet) MarshalJSON() ([]byte, error) {
|
|
if m.automatic != nil {
|
|
return json.Marshal("Automatic")
|
|
} else if m.specific != nil {
|
|
return json.Marshal(m.specific)
|
|
}
|
|
|
|
return nil, errors.New("PositionToSet.MarshalJson()")
|
|
}
|