github.com/stafiprotocol/go-substrate-rpc-client@v1.4.7/types/balance_status.go (about) 1 package types 2 3 import ( 4 "fmt" 5 6 "github.com/stafiprotocol/go-substrate-rpc-client/pkg/scale" 7 ) 8 9 type BalanceStatus byte 10 11 const ( 12 // Funds are free, as corresponding to `free` item in Balances. 13 Free BalanceStatus = 0 14 // Funds are reserved, as corresponding to `reserved` item in Balances. 15 Reserved BalanceStatus = 1 16 ) 17 18 func (bs *BalanceStatus) Decode(decoder scale.Decoder) error { 19 b, err := decoder.ReadOneByte() 20 vb := BalanceStatus(b) 21 switch vb { 22 case Free, Reserved: 23 *bs = vb 24 default: 25 return fmt.Errorf("unknown BalanceStatus enum: %v", vb) 26 } 27 return err 28 } 29 30 func (bs BalanceStatus) Encode(encoder scale.Encoder) error { 31 return encoder.PushByte(byte(bs)) 32 }