Decode converts byte slice to a pointer to Type value. It returns number bytes consumed and an Type value in interface{}.
(b []byte)
| 87 | // Decode converts byte slice to a pointer to Type value. |
| 88 | // It returns number bytes consumed and an Type value in interface{}. |
| 89 | func (m *TypeEncoder) Decode(b []byte) (int, interface{}) { |
| 90 | |
| 91 | b = b[0:m.Size] |
| 92 | v := reflect.New(m.Type) |
| 93 | err := binary.Read(bytes.NewBuffer(b), m.Endian, v.Interface()) |
| 94 | if err != nil { |
| 95 | panic(err) |
| 96 | } |
| 97 | return m.Size, reflect.Indirect(v).Interface() |
| 98 | } |
| 99 | |
| 100 | // GetSize returns m.Size. |
| 101 | func (m *TypeEncoder) GetSize(d interface{}) int { |