Apply a LeafOp (token-level operation).
(
txn: &mut T,
branch_id: BranchId,
leaf_id: LeafId,
leaf_op: &LeafOp,
stats: &mut ApplyFileOpsStats,
)
| 784 | |
| 785 | /// Apply a LeafOp (token-level operation). |
| 786 | fn apply_leaf_op<T: MutTxnT>( |
| 787 | txn: &mut T, |
| 788 | branch_id: BranchId, |
| 789 | leaf_id: LeafId, |
| 790 | leaf_op: &LeafOp, |
| 791 | stats: &mut ApplyFileOpsStats, |
| 792 | ) -> PristineResult<()> { |
| 793 | match leaf_op { |
| 794 | LeafOp::Insert { kind, content, .. } => { |
| 795 | // Create serialized leaf record |
| 796 | // Note: content_start/end would be set during content blob assembly |
| 797 | let serialized = SerializedLeaf { |
| 798 | branch_id, |
| 799 | kind: *kind, |
| 800 | state: LeafState::Alive, |
| 801 | content_start: 0, |
| 802 | content_end: content.len() as u32, |
| 803 | }; |
| 804 | |
| 805 | put_leaf(txn, branch_id, leaf_id, &serialized)?; |
| 806 | stats.leaves_created += 1; |
| 807 | } |
| 808 | |
| 809 | LeafOp::Delete { .. } => { |
| 810 | update_leaf_state(txn, leaf_id, LeafState::Deleted)?; |
| 811 | stats.leaves_deleted += 1; |
| 812 | } |
| 813 | |
| 814 | LeafOp::Replace { new_content, .. } => { |
| 815 | // Replace keeps the same leaf ID but changes content |
| 816 | update_leaf_content(txn, leaf_id, new_content)?; |
| 817 | stats.leaves_replaced += 1; |
| 818 | } |
| 819 | |
| 820 | LeafOp::Restore { .. } => { |
| 821 | update_leaf_state(txn, leaf_id, LeafState::Alive)?; |
| 822 | stats.leaves_restored += 1; |
| 823 | } |
| 824 | } |
| 825 | |
| 826 | Ok(()) |
| 827 | } |
| 828 | |
| 829 | /// Convert Encoding to u8 for storage. |
| 830 | fn encoding_to_u8(encoding: Option<&Encoding>) -> u8 { |
no test coverage detected