initial commit
This commit is contained in:
75
model_output_toset.go
Normal file
75
model_output_toset.go
Normal file
@ -0,0 +1,75 @@
|
||||
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()")
|
||||
}
|
Reference in New Issue
Block a user