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
/*
* SPDX-License-Identifier: MIT
* Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
*/
use crate::;
/// A store that holds values and hands back references to them.
///
/// A store that holds structure and not values accepts a data node only as a
/// [`DataRecord::Reference`]. The substrate is where the value then lives: `deposit` stores a
/// record under the node that carries it and returns where it now lives, and `resolve` returns
/// the record a reference names.
///
/// `deposit` is idempotent per node: it holds at most one value for a node, a deposit under a node
/// replaces the value deposited under it before, and every deposit under a node returns the same
/// reference. A retried deposit therefore adds nothing and hands back the reference the first one
/// did; a caller that must keep a value a store already references checks before it deposits.
///
/// `deposit` is given any record other than a `Reference`; a substrate refuses a `Reference` with
/// its own error, because a reference to a reference names nothing. `resolve` refuses a reference
/// it does not hold.