Update a leaf's state.
(
txn: &mut T,
leaf_id: LeafId,
state: LeafState,
)
| 1129 | |
| 1130 | /// Update a leaf's state. |
| 1131 | fn update_leaf_state<T: MutTxnT>( |
| 1132 | txn: &mut T, |
| 1133 | leaf_id: LeafId, |
| 1134 | state: LeafState, |
| 1135 | ) -> PristineResult<()> { |
| 1136 | let key = encode_leaf_id(&leaf_id); |
| 1137 | |
| 1138 | // Get existing leaf |
| 1139 | if let Some(mut serialized) = txn.get_crdt_leaf(&key)? { |
| 1140 | // Update state |
| 1141 | serialized.state = state; |
| 1142 | |
| 1143 | // Re-encode and store |
| 1144 | let value = encode_leaf_value(&serialized); |
| 1145 | txn.put_crdt_leaf(&key, &value)?; |
| 1146 | } |
| 1147 | |
| 1148 | Ok(()) |
| 1149 | } |
| 1150 | |
| 1151 | /// Update a leaf's content. |
| 1152 | fn update_leaf_content<T: MutTxnT>( |
no test coverage detected