diff options
| author | eunhhu <[email protected]> | 2026-09-25 11:57:33 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-25 11:57:33 +0100 |
| commit | 08056bb65bb9d1cfa4ccb1cd0b9cb67554d560a3 (patch) | |
| tree | 4955dd22c1a1602264c1502181dd2ebd20cbec0c /prototypes/connections/state.h | |
| parent | efba82d75e4357c7e82b027b04a5ec9937f8443b (diff) | |
| download | pure-08056bb65bb9d1cfa4ccb1cd0b9cb67554d560a3.tar.gz pure-08056bb65bb9d1cfa4ccb1cd0b9cb67554d560a3.zip | |
Allow drafts without a stored base
Runtime-owned values such as an app's text need the same extent tree as
stored documents without a store file. pure_draft_new creates such a draft;
it edits, lends versions and reclaims like any draft but refuses to commit.
pure_draft_restore returns a held draft to an earlier version, so a failed
event can abandon its edits. A test runs 4,000 random edits with a fifth
abandoned against a flat oracle under ASan/UBSan.
Diffstat (limited to 'prototypes/connections/state.h')
| -rw-r--r-- | prototypes/connections/state.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/prototypes/connections/state.h b/prototypes/connections/state.h index d0b386c..461f71a 100644 --- a/prototypes/connections/state.h +++ b/prototypes/connections/state.h @@ -12,6 +12,9 @@ * appends only the draft's new extents. One owner thread per draft. */ typedef struct PureDraft PureDraft; +/* A working value with no stored base, for runtime-owned state such as an + * app's text. It edits and reads like any draft but cannot be committed. */ +PureDraft *pure_draft_new(void); /* A missing key opens as an empty draft at revision 0; commit creates it. */ PureResult pure_draft_open(const char *path, const char *key, PureDraft **out); /* Memory only. Fails without change on a bad range or when memory runs out. */ @@ -32,6 +35,8 @@ PureResult pure_draft_read_version(const PureDraft *, PureVersion, size_t offset bool (*visit)(void *, PureSpan), void *context); /* While held, edits keep every earlier version's nodes (one transaction). */ void pure_draft_hold(PureDraft *, bool held); +/* Abandon edits made since version was taken; the draft was held since then. */ +void pure_draft_restore(PureDraft *, PureVersion); /* Publish if the key is still at the draft's base revision. On success the * draft continues from the new revision; on any failure it is unchanged. */ PureResult pure_draft_commit(PureDraft *, int64_t *revision); |
