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

Function update_leaf_state

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

Update a leaf's state.

(
    txn: &mut T,
    leaf_id: LeafId,
    state: LeafState,
)

Source from the content-addressed store, hash-verified

969
970/// Update a leaf's state.
971fn update_leaf_state<T: MutTxnT>(
972 txn: &mut T,
973 leaf_id: LeafId,
974 state: LeafState,
975) -> PristineResult<()> {
976 let key = encode_leaf_id(&leaf_id);
977
978 // Get existing leaf
979 if let Some(mut serialized) = txn.get_crdt_leaf(&key)? {
980 // Update state
981 serialized.state = state;
982
983 // Re-encode and store
984 let value = encode_leaf_value(&serialized);
985 txn.put_crdt_leaf(&key, &value)?;
986 }
987
988 Ok(())
989}
990
991/// Update a leaf's content.
992fn update_leaf_content<T: MutTxnT>(

Callers 1

apply_leaf_opFunction · 0.85

Calls 4

encode_leaf_idFunction · 0.85
encode_leaf_valueFunction · 0.85
put_crdt_leafMethod · 0.80
get_crdt_leafMethod · 0.45

Tested by

no test coverage detected