Decode reads the whole index object from its input and stores it in the value pointed to by idx.
(idx *Index)
| 64 | // Decode reads the whole index object from its input and stores it in the |
| 65 | // value pointed to by idx. |
| 66 | func (d *Decoder) Decode(idx *Index) error { |
| 67 | var err error |
| 68 | idx.Version, err = validateHeader(d.r) |
| 69 | if err != nil { |
| 70 | return err |
| 71 | } |
| 72 | |
| 73 | entryCount, err := binary.ReadUint32(d.r) |
| 74 | if err != nil { |
| 75 | return err |
| 76 | } |
| 77 | |
| 78 | if err := d.readEntries(idx, int(entryCount)); err != nil { |
| 79 | return err |
| 80 | } |
| 81 | |
| 82 | return d.readExtensions(idx) |
| 83 | } |
| 84 | |
| 85 | func (d *Decoder) readEntries(idx *Index, count int) error { |
| 86 | for i := 0; i < count; i++ { |