restore_raw_owner.bend
bendvy-ecs-core@0.1.0.1 · 22 lines · 0 definitions
1import Base
2import bendvy-ecs-core@0.1.0.1/decode_data.bend as D
3import bendvy-ecs-core@0.1.0.1/snapshot_data.bend as Snapshot
4import bendvy-ecs-core@0.1.0.1/restore_raw.bend as Raw
5
6# ParseRejected returns actual unchanged owner/runtime with original Raw/error.
7# Delivered retains original Raw beside the restore callback's actual Output;
8# its inner outcome/recovery determines semantic restore success or refusal.
9type Returned<Owner:Type,Runtime:Type,Output:Type> is Type:
10 ParseRejected{owner:Owner,runtime:Runtime,original:D.Raw,error:Raw.Error}
11 Delivered{original:D.Raw,output:Output}
12def parsed(~Owner:Type,~Runtime:Type,~Output:Type,~run:Owner -> Runtime -> Snapshot.Snapshot -> Output,+original:D.Raw,owner:Owner,runtime:Runtime,result:Raw.Parsed) -> Returned<Owner,Runtime,Output>:
13 match result:
14 case Raw.Rejected{input,error}:ParseRejected{owner,runtime,input,error}
15 case Raw.Accepted{snapshot}:Delivered{original,run(owner,runtime,snapshot)}
16# Parse before invoking the closed typed restore callback. Parse failure does not
17# call restore or consume its actual owners; success transfers owner/runtime and
18# Snapshot exactly once. Callback Output must retain whatever owners/results its
19# contract requires; this generic wrapper adds no rollback or recovery guarantee.
20# See docs/parity/restore-basic.md and its RawOwner.run consumer.
21def run(~Owner:Type,~Runtime:Type,~Output:Type,~restore:Owner -> Runtime -> Snapshot.Snapshot -> Output,owner:Owner,runtime:Runtime,+input:D.Raw) -> Returned<Owner,Runtime,Output>:
22 parsed(~Owner,~Runtime,~Output,~restore,input,owner,runtime,Raw.parse(input))