2021-11-20 19:38:31 -10:00
|
|
|
package grow
|
2021-11-20 18:51:19 -10:00
|
|
|
|
|
|
|
|
import "io"
|
|
|
|
|
|
|
|
|
|
import "gopkg.in/yaml.v2"
|
|
|
|
|
|
|
|
|
|
type Definition struct {
|
|
|
|
|
GlobalMemorySize uint64 `yaml:"global_memory_size"`
|
|
|
|
|
FunctionMemorySize uint64 `yaml:"function_memory_size"`
|
2021-11-20 19:25:16 -10:00
|
|
|
InstructionLimit uint64 `yaml:"instruction_limit"`
|
2021-11-20 18:51:19 -10:00
|
|
|
Samples []*Sample `yaml:"samples"`
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-20 19:17:35 -10:00
|
|
|
func NewDefinition(r io.Reader) (*Definition, error) {
|
2021-11-20 18:51:19 -10:00
|
|
|
dec := yaml.NewDecoder(r)
|
|
|
|
|
dec.SetStrict(true)
|
|
|
|
|
|
|
|
|
|
def := &Definition{}
|
|
|
|
|
|
|
|
|
|
err := dec.Decode(def)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return def, nil
|
|
|
|
|
}
|