Update a leaf's state.
(
txn: &mut T,
leaf_id: LeafId,
state: LeafState,
)
| 969 | |
| 970 | /// Update a leaf's state. |
| 971 | fn update_leaf_state<T: MutTxnT>( |
| 972 | txn: &mut T, |
| 973 | leaf_id: LeafId, |
| 974 | state: LeafState, |
| 975 | ) -> PristineResult<()> { |
| 976 | let key = encode_leaf_id(&leaf_id); |
| 977 | |
| 978 | // Get existing leaf |
| 979 | if let Some(mut serialized) = txn.get_crdt_leaf(&key)? { |
| 980 | // Update state |
| 981 | serialized.state = state; |
| 982 | |
| 983 | // Re-encode and store |
| 984 | let value = encode_leaf_value(&serialized); |
| 985 | txn.put_crdt_leaf(&key, &value)?; |
| 986 | } |
| 987 | |
| 988 | Ok(()) |
| 989 | } |
| 990 | |
| 991 | /// Update a leaf's content. |
| 992 | fn update_leaf_content<T: MutTxnT>( |
no test coverage detected