EncodeToReader returns a reader from which the RLP encoding of val can be read. The returned size is the total size of the encoded data. Please see the documentation of Encode for the encoding rules.
(val interface{})
| 83 | // |
| 84 | // Please see the documentation of Encode for the encoding rules. |
| 85 | func EncodeToReader(val interface{}) (size int, r io.Reader, err error) { |
| 86 | eb := encbufPool.Get().(*encbuf) |
| 87 | eb.reset() |
| 88 | if err := eb.encode(val); err != nil { |
| 89 | return 0, nil, err |
| 90 | } |
| 91 | return eb.size(), &encReader{buf: eb}, nil |
| 92 | } |
| 93 | |
| 94 | type listhead struct { |
| 95 | offset int // index of this header in string data |