docs: Snapshot snapshot() {
      Snapshot snapshot = raft.getSnapshotStore().newTemporarySnapshot(raft.getLastApplied(), new WallClockTimestamp());
      try (SnapshotWriter writer = snapshot.openWriter()) {
        for (RaftServiceContext service : raft.getServices()) {
          writer.buffer().mark();
          SnapshotWriter serviceWriter = new SnapshotWriter(writer.buffer().writeInt(0).slice(), writer.snapshot());
          snapshotService(serviceWriter, service);
          int length = serviceWriter.buffer().position();
          writer.buffer().reset().writeInt(length).skip(length);
        }
      } catch (Exception e) {
        snapshot.close();
        logger.error("Failed to snapshot services", e);
        throw e;
      }
      return snapshot;
    }