feat: new engine format

This commit is contained in:
2026-02-07 00:12:50 -05:00
parent 8b80cea32b
commit 1d94fa70ff
11 changed files with 45 additions and 100 deletions

View File

@@ -7,7 +7,7 @@ import (
)
type Engine interface {
Load() Process
Load(Repr) (Process, error)
Name() string
InType() string
}
@@ -22,8 +22,18 @@ func (e convertedEngine[T]) InType() string { return e.inType }
func (e convertedEngine[T]) Name() string { return e.name }
func (e convertedEngine[T]) Load() Process {
return convertedProcess[T]{e.engine.Load(), e.inType}
func (e convertedEngine[T]) Load(r Repr) (Process, error) {
t, ok := r.Data().(T)
if !ok {
return nil, fmt.Errorf("'ncorrent format '%s' for engine '%s'", r.ID(), e.inType)
}
process, err := e.engine(t)
if err != nil {
return nil, err
}
return convertedProcess[T]{process, e.inType}, nil
}
func RegisterEngine[T any](registry *Registry, e engine.Engine[T], name, inType string) error {