Update a trunk's path.
(
txn: &mut T,
trunk_id: TrunkId,
new_path: &str,
)
| 883 | |
| 884 | /// Update a trunk's path. |
| 885 | fn update_trunk_path<T: MutTxnT>( |
| 886 | txn: &mut T, |
| 887 | trunk_id: TrunkId, |
| 888 | new_path: &str, |
| 889 | ) -> PristineResult<()> { |
| 890 | let key = encode_trunk_id(&trunk_id); |
| 891 | |
| 892 | // Get existing trunk |
| 893 | if let Some(mut serialized) = txn.get_crdt_trunk(&key)? { |
| 894 | // Remove old path index |
| 895 | txn.del_crdt_path_trunk(&serialized.path)?; |
| 896 | |
| 897 | // Update path |
| 898 | serialized.path = new_path.to_string(); |
| 899 | |
| 900 | // Re-encode and store |
| 901 | let value = encode_trunk_value(&serialized); |
| 902 | txn.put_crdt_trunk(&key, &value)?; |
| 903 | |
| 904 | // Add new path index |
| 905 | txn.put_crdt_path_trunk(new_path, &key)?; |
| 906 | } |
| 907 | |
| 908 | Ok(()) |
| 909 | } |
| 910 | |
| 911 | /// Store a branch in the CRDT tables. |
| 912 | fn put_branch<T: MutTxnT>( |
no test coverage detected