MCPcopy
hub / github.com/openacid/slim / Decode

Method Decode

encode/type_encoder.go:89–98  ·  view source on GitHub ↗

Decode converts byte slice to a pointer to Type value. It returns number bytes consumed and an Type value in interface{}.

(b []byte)

Source from the content-addressed store, hash-verified

87// Decode converts byte slice to a pointer to Type value.
88// It returns number bytes consumed and an Type value in interface{}.
89func (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.
101func (m *TypeEncoder) GetSize(d interface{}) int {

Callers

nothing calls this directly

Calls 1

ReadMethod · 0.65

Tested by

no test coverage detected