feat: add RowConsumption & RowUsage types (#625)

This commit is contained in:
HAOYUatHZ 2024-01-31 10:41:51 +08:00 committed by GitHub
parent 14d8266fc2
commit 001a80226a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 56 additions and 0 deletions

View file

@ -0,0 +1,41 @@
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package types
import (
"encoding/json"
"errors"
)
// MarshalJSON marshals as JSON.
func (s SubCircuitRowUsage) MarshalJSON() ([]byte, error) {
type SubCircuitRowUsage struct {
Name string `json:"name" gencodec:"required"`
RowNumber uint64 `json:"row_number" gencodec:"required"`
}
var enc SubCircuitRowUsage
enc.Name = s.Name
enc.RowNumber = s.RowNumber
return json.Marshal(&enc)
}
// UnmarshalJSON unmarshals from JSON.
func (s *SubCircuitRowUsage) UnmarshalJSON(input []byte) error {
type SubCircuitRowUsage struct {
Name *string `json:"name" gencodec:"required"`
RowNumber *uint64 `json:"row_number" gencodec:"required"`
}
var dec SubCircuitRowUsage
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
if dec.Name == nil {
return errors.New("missing required field 'name' for SubCircuitRowUsage")
}
s.Name = *dec.Name
if dec.RowNumber == nil {
return errors.New("missing required field 'row_number' for SubCircuitRowUsage")
}
s.RowNumber = *dec.RowNumber
return nil
}

View file

@ -0,0 +1,15 @@
package types
type RowUsage struct {
IsOk bool `json:"is_ok"`
RowNumber uint64 `json:"row_number"`
RowUsageDetails []SubCircuitRowUsage `json:"row_usage_details"`
}
//go:generate gencodec -type SubCircuitRowUsage -out gen_row_consumption_json.go
type SubCircuitRowUsage struct {
Name string `json:"name" gencodec:"required"`
RowNumber uint64 `json:"row_number" gencodec:"required"`
}
type RowConsumption []SubCircuitRowUsage