Apply a LeafOp (token-level operation).
(
txn: &mut T,
branch_id: BranchId,
leaf_id: LeafId,
leaf_op: &LeafOp,
stats: &mut ApplyFileOpsStats,
)
| 927 | |
| 928 | /// Apply a LeafOp (token-level operation). |
| 929 | fn apply_leaf_op<T: MutTxnT>( |
| 930 | txn: &mut T, |
| 931 | branch_id: BranchId, |
| 932 | leaf_id: LeafId, |
| 933 | leaf_op: &LeafOp, |
| 934 | stats: &mut ApplyFileOpsStats, |
| 935 | ) -> PristineResult<()> { |
| 936 | match leaf_op { |
| 937 | LeafOp::Insert { kind, content, .. } => { |
| 938 | // Create serialized leaf record |
| 939 | // Note: content_start/end would be set during content blob assembly |
| 940 | let serialized = SerializedLeaf { |
| 941 | branch_id, |
| 942 | kind: *kind, |
| 943 | state: LeafState::Alive, |
| 944 | content_start: 0, |
| 945 | content_end: content.len() as u32, |
| 946 | }; |
| 947 | |
| 948 | put_leaf(txn, branch_id, leaf_id, &serialized)?; |
| 949 | stats.leaves_created += 1; |
| 950 | } |
| 951 | |
| 952 | LeafOp::Delete { .. } => { |
| 953 | update_leaf_state(txn, leaf_id, LeafState::Deleted)?; |
| 954 | stats.leaves_deleted += 1; |
| 955 | } |
| 956 | |
| 957 | LeafOp::Replace { new_content, .. } => { |
| 958 | // Replace keeps the same leaf ID but changes content |
| 959 | update_leaf_content(txn, leaf_id, new_content)?; |
| 960 | stats.leaves_replaced += 1; |
| 961 | } |
| 962 | |
| 963 | LeafOp::Restore { .. } => { |
| 964 | update_leaf_state(txn, leaf_id, LeafState::Alive)?; |
| 965 | stats.leaves_restored += 1; |
| 966 | } |
| 967 | } |
| 968 | |
| 969 | Ok(()) |
| 970 | } |
| 971 | |
| 972 | /// Convert Encoding to u8 for storage. |
| 973 | fn encoding_to_u8(encoding: Option<&Encoding>) -> u8 { |
no test coverage detected