code: func (f *fsmSnapshot) Persist(sink raft.SnapshotSink) error {
  	// sizeWriter writes the size of given byte slize to the
  	// raft sink, followed by the byte slice itself.
  	sizeWriter := func(s raft.SnapshotSink, b []byte) error {
  		buf := new(bytes.Buffer)
  		sz := uint64(len(b))
  		err := binary.Write(buf, binary.LittleEndian, sz)
  		if err != nil {
  			return err
  		}
  		if _, err := s.Write(buf.Bytes()); err != nil {
  			return err
  		}
  		if _, err := s.Write(b); err != nil {
  			return err
  		}
  		return nil
  	}
  
  	if err := func() error {
  		for _, b := range [][]byte{f.database, f.meta, f.connections} {
  			if err := sizeWriter(sink, b); err != nil {
  				return err
  			}
  		}
  		// Close the sink.
  		return sink.Close()
  	}(); err != nil {
  		sink.Cancel()
  		return err
  	}
  
  	return nil
  }
docs: // Persist writes the snapshot to the given sink.