aboutsummaryrefslogtreecommitdiffstats
path: root/core/module-save.h
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-09-27 13:14:38 +0100
committereunhhu <[email protected]>2026-09-27 13:14:38 +0100
commit37d3a1e152707d2da587440c4cea8601b9ef0fd2 (patch)
tree1a4cbea9d8ca636deabd8fc24b0d73cdae2bdaef /core/module-save.h
parent5372d03b5968796515966e2cfc89628d6448f0c1 (diff)
downloadpure-37d3a1e152707d2da587440c4cea8601b9ef0fd2.tar.gz
pure-37d3a1e152707d2da587440c4cea8601b9ef0fd2.zip
Lay Pure out as a core with the parts selected around it
The app model, the tree store and the HTTP host lived in prototypes/connections among the earlier document runtime, the store was known only by its format's name, and Vega compiled six Pure sources by path. Now, as the README's principle has it: core/ runtime, flow and the app model (module*.c), with what the core asks of storage (state.h, store.h) store/ the tree store (PURETRE3, PUREREC1) serve/ pure-serve: HTTP host, outbound delivery, JSON in place cli/ pure-run, pure-edit-module A top-level make builds libpure.a (app model and store, for hosts to link) and the hosts; make check runs the store's and the app model's tests. The earlier runtime still builds from prototypes/connections against core/ and store/ (check, check-tree and check-core pass). Design 009 records the rule: parts by role behind libraries; git repositories split by coupling, so the store stays here while its contract moves with the core, and Vega stays apart.
Diffstat (limited to 'core/module-save.h')
-rw-r--r--core/module-save.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/core/module-save.h b/core/module-save.h
new file mode 100644
index 0000000..bc7adcc
--- /dev/null
+++ b/core/module-save.h
@@ -0,0 +1,36 @@
+#ifndef PURE_MODULE_SAVE_H
+#define PURE_MODULE_SAVE_H
+#include "module.h"
+
+/* App states a data host keeps (docs/design/008-module-format.md), internal
+ * to the module executor. Each text state is a stored draft, each list state
+ * a stored draft its list mirrors, and numbers, cursors and indices are one
+ * stored value by name. A save publishes what changed, all or nothing. */
+
+bool pure_save_enabled(const PureApp *);
+/* A text state of m: its stored value, or its initial constant when none. */
+PureResult pure_save_open_text(PureApp *, const PureModule *m, uint32_t state, PureDraft **out, PureVersion *saved);
+/* A list state of m: its stored items, fields moved by name when the stored
+ * record differs from m's. */
+PureResult pure_save_open_list(PureApp *, const PureModule *m, uint32_t state, PureList **out, PureDraft **draft,
+ PureVersion *saved);
+/* Open the stored numbers, cursors and indices, and put each stored one of the
+ * same name and kind that still fits into values, for the states of m that
+ * kept marks as new (-1); texts and lists are m's. */
+PureResult pure_save_open_values(PureApp *, const PureModule *m, double *values, const int *kept,
+ PureDraft *const *texts, PureList *const *lists);
+/* Store a list whose record changed in its draft, header and items anew. */
+PureResult pure_save_rewrite_list(const PureModule *m, uint32_t state, PureList *list, PureDraft *draft);
+/* The stored links of a starting app (module.h, PureApp); CONFLICT when an
+ * output with sends left is missing or has other fields. */
+PureResult pure_save_open_links(PureApp *, const PureModule *m);
+/* Publish the documents and every state changed since the last save
+ * (values are the states' numbers); revisions are the documents'. */
+PureResult pure_save_commit(PureApp *, const double *values, void *const *documents, size_t document_count,
+ int64_t *revisions);
+
+/* A list with record's fields, taking from `from` each field of the same name
+ * and kind and giving the others their defaults (module.c). */
+PureResult pure_list_migrate(PureList **out, const PureList *from, const char *const *names,
+ const uint8_t *text, unsigned count, const PureModule *m, uint32_t record);
+#endif