pub fn validate_reparent(
conn: &Connection,
item_id: &str,
new_parent_id: &str,
) -> Result<(), HierarchyError>Expand description
Validate that reparenting item_id under new_parent_id is allowed.
This checks:
- Both items exist.
- The new parent is of kind
goal. - The move would not create a cycle (i.e.,
new_parent_idis not a descendant ofitem_id).
On success returns Ok(()). On failure returns the appropriate
HierarchyError variant.
ยงErrors
Returns HierarchyError::ItemNotFound if either item does not exist,
HierarchyError::NotAGoal if the new parent is not a goal, or
HierarchyError::CycleDetected if the move would create a cycle.