code: func (s *snapshot) Persist(sink raft.SnapshotSink) error {
  	defer metrics.MeasureSince([]string{"fsm", "persist"}, time.Now())
  
  	// Write the header
  	header := snapshotHeader{
  		LastIndex: s.state.LastIndex(),
  	}
  	encoder := codec.NewEncoder(sink, msgpackHandle)
  	if err := encoder.Encode(&header); err != nil {
  		sink.Cancel()
  		return err
  	}
  
  	// Run all the persisters to write the FSM state.
  	for _, fn := range persisters {
  		if err := fn(s, sink, encoder); err != nil {
  			sink.Cancel()
  			return err
  		}
  	}
  	return nil
  }
docs: // Persist saves the FSM snapshot out to the given sink.