code: func (e *Encoder) Encode(idx *Index) error {
  	// TODO: support versions v3 and v4
  	// TODO: support extensions
  	if idx.Version != EncodeVersionSupported {
  		return ErrUnsupportedVersion
  	}
  
  	if err := e.encodeHeader(idx); err != nil {
  		return err
  	}
  
  	if err := e.encodeEntries(idx); err != nil {
  		return err
  	}
  
  	return e.encodeFooter()
  }
docs: // Encode writes the Index to the stream of the encoder.