From ef97d4703cfd08a4ccc3c00dac7cf84877875245 Mon Sep 17 00:00:00 2001 From: Brian Potchik Date: Thu, 6 Mar 2025 19:54:50 -0500 Subject: Add API to insert Activities after a specified Activity. --- rust/src/workflow.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'rust/src') diff --git a/rust/src/workflow.rs b/rust/src/workflow.rs index e95beb48..dcc388d9 100644 --- a/rust/src/workflow.rs +++ b/rust/src/workflow.rs @@ -529,6 +529,34 @@ impl Workflow { } } + /// Insert the list of `activities` after the specified `activity` and at the same level. + /// + /// * `activity` - the Activity node for which to insert `activities` after + /// * `activities` - the list of Activities to insert + pub fn insert_after(&self, activity: A, activities: I) -> bool + where + A: BnStrCompatible, + I: IntoIterator, + I::Item: BnStrCompatible, + { + let input_list: Vec<_> = activities + .into_iter() + .map(|a| a.into_bytes_with_nul()) + .collect(); + let mut input_list_ptr: Vec<*const _> = input_list + .iter() + .map(|x| x.as_ref().as_ptr() as *const c_char) + .collect(); + unsafe { + BNWorkflowInsertAfter( + self.handle.as_ptr(), + activity.into_bytes_with_nul().as_ref().as_ptr() as *const c_char, + input_list_ptr.as_mut_ptr(), + input_list.len(), + ) + } + } + /// Remove the specified `activity` pub fn remove(&self, activity: A) -> bool { unsafe { -- cgit v1.3.1