-
Notifications
You must be signed in to change notification settings - Fork 12
/
types.go
64 lines (49 loc) · 937 Bytes
/
types.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
// Code generated by scale-signature , DO NOT EDIT.
// output: signature
package host
import (
"errors"
"github.com/loopholelabs/polyglot"
)
var (
NilDecode = errors.New("cannot decode into a nil root struct")
InvalidEnum = errors.New("invalid enum value")
)
type Context struct {
Data string
}
func NewContext() *Context {
return &Context{
Data: "",
}
}
func (x *Context) Encode(b *polyglot.Buffer) {
e := polyglot.Encoder(b)
if x == nil {
e.Nil()
} else {
e.String(x.Data)
}
}
func DecodeContext(x *Context, b []byte) (*Context, error) {
d := polyglot.GetDecoder(b)
defer d.Return()
return _decodeContext(x, d)
}
func _decodeContext(x *Context, d *polyglot.Decoder) (*Context, error) {
if d.Nil() {
return nil, nil
}
err, _ := d.Error()
if err != nil {
return nil, err
}
if x == nil {
x = NewContext()
}
x.Data, err = d.String()
if err != nil {
return nil, err
}
return x, nil
}