1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Stepwise schema migration for block-stored JSON.
//!
//! When a block's [`crate::Block::version`] is bumped, every load
//! comparing the *stored* version on a JSON entry to the *current*
//! version triggers [`apply_migrations`], which walks each integer
//! version between them calling [`crate::Block::migrate`] once per
//! step. Authors write single-version-step migrators only; the
//! framework chains them.
//!
//! ## Wire-format version
//!
//! The JSON envelope of a block entry stores `version: u32` next to
//! `type` / `id` / `value` (explicit per-item versions beat
//! implicit ones). Missing
//! `version` is treated as `1` (the initial baseline).
use Value;
use ;
/// Read the stored version off a `{type, id, value, version?}`
/// envelope. Missing / non-integer falls back to `1` so legacy
/// streams that pre-date version-stamping just sail through unchanged
/// (their `migrate(1, …)` for blocks at v1 is a no-op).
/// Apply every step between `stored` and `block.version()` in order.
/// Each step gets the previous step's output. Already-current values
/// (or future values stored by a newer process) short-circuit.
///
/// # Errors
/// First failing [`crate::Block::migrate`] short-circuits with
/// [`BlockError::MigrateFailed`] carrying the offending step.
Sized>