-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgen_avaiable_json.go
More file actions
54 lines (50 loc) · 1.51 KB
/
gen_avaiable_json.go
File metadata and controls
54 lines (50 loc) · 1.51 KB
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
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package inference
import (
"encoding/json"
"errors"
)
// MarshalJSON marshals as JSON.
func (a AvailableWork) MarshalJSON() ([]byte, error) {
type AvailableWork struct {
Type InferType `json:"type" gencodec:"required"`
InfoHash string `json:"infohash" gencodec:"required"`
RawSize uint64 `json:"rawSize" gencodec:"required"`
CvmNetworkId int64 `json:"cvm_networkid"`
}
var enc AvailableWork
enc.Type = a.Type
enc.InfoHash = a.InfoHash
enc.RawSize = a.RawSize
enc.CvmNetworkId = a.CvmNetworkId
return json.Marshal(&enc)
}
// UnmarshalJSON unmarshals from JSON.
func (a *AvailableWork) UnmarshalJSON(input []byte) error {
type AvailableWork struct {
Type *InferType `json:"type" gencodec:"required"`
InfoHash *string `json:"infohash" gencodec:"required"`
RawSize *uint64 `json:"rawSize" gencodec:"required"`
CvmNetworkId *int64 `json:"cvm_networkid"`
}
var dec AvailableWork
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
if dec.Type == nil {
return errors.New("missing required field 'type' for AvailableWork")
}
a.Type = *dec.Type
if dec.InfoHash == nil {
return errors.New("missing required field 'infohash' for AvailableWork")
}
a.InfoHash = *dec.InfoHash
if dec.RawSize == nil {
return errors.New("missing required field 'rawSize' for AvailableWork")
}
a.RawSize = *dec.RawSize
if dec.CvmNetworkId != nil {
a.CvmNetworkId = *dec.CvmNetworkId
}
return nil
}