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

Function update_trunk_state

atomic-core/src/apply/file_ops.rs:864–882  ·  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

862
863/// Update a trunk's state.
864fn update_trunk_state<T: MutTxnT>(
865 txn: &mut T,
866 trunk_id: TrunkId,
867 state: TrunkState,
868) -> PristineResult<()> {
869 let key = encode_trunk_id(&trunk_id);
870
871 // Get existing trunk
872 if let Some(mut serialized) = txn.get_crdt_trunk(&key)? {
873 // Update state in the serialized data
874 serialized.state = state;
875
876 // Re-encode and store
877 let value = encode_trunk_value(&serialized);
878 txn.put_crdt_trunk(&key, &value)?;
879 }
880
881 Ok(())
882}
883
884/// Update a trunk's path.
885fn 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