MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / update_trunk_state

Function update_trunk_state

atomic-core/src/apply/file_ops.rs:1021–1039  ·  view source on GitHub ↗

Update a trunk's state.

(
    txn: &mut T,
    trunk_id: TrunkId,
    state: TrunkState,
)

Source from the content-addressed store, hash-verified

1019
1020/// Update a trunk's state.
1021fn 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.
1042fn update_trunk_path<T: MutTxnT>(

Callers 1

apply_trunk_opFunction · 0.85

Calls 4

encode_trunk_idFunction · 0.85
encode_trunk_valueFunction · 0.85
put_crdt_trunkMethod · 0.80
get_crdt_trunkMethod · 0.45

Tested by

no test coverage detected