Files
lambda/internal/cli/process.go

42 lines
717 B
Go

package cli
import (
"fmt"
"git.maximhutz.com/max/lambda/pkg/engine"
)
type Process interface {
engine.Process[Repr]
InType() string
}
type convertedProcess[T any] struct {
process engine.Process[T]
inType string
}
func (e convertedProcess[T]) InType() string { return e.inType }
func (b convertedProcess[T]) Get() (Repr, error) {
s, err := b.process.Get()
if err != nil {
return nil, err
}
return NewRepr(b.inType, s), nil
}
func (b convertedProcess[T]) Set(r Repr) error {
if t, ok := r.Data().(T); ok {
return b.process.Set(t)
}
return fmt.Errorf("Incorrent format '%s' for engine '%s'.", r.Id(), b.inType)
}
func (b convertedProcess[T]) Step(i int) bool {
return b.process.Step(i)
}