Update a trunk's state.
(
txn: &mut T,
trunk_id: TrunkId,
state: TrunkState,
)
| 1019 | |
| 1020 | /// Update a trunk's state. |
| 1021 | fn update_trunk_state<T: MutTxnT>( |
| 1022 | txn: &mut T, |
| 1023 | trunk_id: TrunkId, |
| 1024 | state: TrunkState, |
| 1025 | ) -> PristineResult<()> { |
| 1026 | let key = encode_trunk_id(&trunk_id); |
| 1027 | |
| 1028 | // Get existing trunk |
| 1029 | if let Some(mut serialized) = txn.get_crdt_trunk(&key)? { |
| 1030 | // Update state in the serialized data |
| 1031 | serialized.state = state; |
| 1032 | |
| 1033 | // Re-encode and store |
| 1034 | let value = encode_trunk_value(&serialized); |
| 1035 | txn.put_crdt_trunk(&key, &value)?; |
| 1036 | } |
| 1037 | |
| 1038 | Ok(()) |
| 1039 | } |
| 1040 | |
| 1041 | /// Update a trunk's path. |
| 1042 | fn update_trunk_path<T: MutTxnT>( |
no test coverage detected