-
Notifications
You must be signed in to change notification settings - Fork 4
/
gen_ic_json.go
68 lines (63 loc) · 1.88 KB
/
gen_ic_json.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package inference
import (
"encoding/json"
"errors"
"github.com/CortexFoundation/CortexTheseus/common/hexutil"
)
// MarshalJSON marshals as JSON.
func (i ICWork) MarshalJSON() ([]byte, error) {
type ICWork struct {
Type InferType `json:"type" gencodec:"required"`
Model string `json:"model" gencodec:"required"`
Input hexutil.Bytes `json:"input" gencodec:"required"`
ModelSize uint64 `json:"modelSize"`
CvmVersion int `json:"cvm_version"`
CvmNetworkId int64 `json:"cvm_networkid"`
}
var enc ICWork
enc.Type = i.Type
enc.Model = i.Model
enc.Input = i.Input
enc.ModelSize = i.ModelSize
enc.CvmVersion = i.CvmVersion
enc.CvmNetworkId = i.CvmNetworkId
return json.Marshal(&enc)
}
// UnmarshalJSON unmarshals from JSON.
func (i *ICWork) UnmarshalJSON(input []byte) error {
type ICWork struct {
Type *InferType `json:"type" gencodec:"required"`
Model *string `json:"model" gencodec:"required"`
Input *hexutil.Bytes `json:"input" gencodec:"required"`
ModelSize *uint64 `json:"modelSize"`
CvmVersion *int `json:"cvm_version"`
CvmNetworkId *int64 `json:"cvm_networkid"`
}
var dec ICWork
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
if dec.Type == nil {
return errors.New("missing required field 'type' for ICWork")
}
i.Type = *dec.Type
if dec.Model == nil {
return errors.New("missing required field 'model' for ICWork")
}
i.Model = *dec.Model
if dec.Input == nil {
return errors.New("missing required field 'input' for ICWork")
}
i.Input = *dec.Input
if dec.ModelSize != nil {
i.ModelSize = *dec.ModelSize
}
if dec.CvmVersion != nil {
i.CvmVersion = *dec.CvmVersion
}
if dec.CvmNetworkId != nil {
i.CvmNetworkId = *dec.CvmNetworkId
}
return nil
}