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