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

Function update_leaf_state

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

1129
1130/// Update a leaf's state.
1131fn update_leaf_state<T: MutTxnT>(
1132 txn: &mut T,
1133 leaf_id: LeafId,
1134 state: LeafState,
1135) -> PristineResult<()> {
1136 let key = encode_leaf_id(&leaf_id);
1137
1138 // Get existing leaf
1139 if let Some(mut serialized) = txn.get_crdt_leaf(&key)? {
1140 // Update state
1141 serialized.state = state;
1142
1143 // Re-encode and store
1144 let value = encode_leaf_value(&serialized);
1145 txn.put_crdt_leaf(&key, &value)?;
1146 }
1147
1148 Ok(())
1149}
1150
1151/// Update a leaf's content.
1152fn 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