@@ -392,6 +392,17 @@ impl LifecycleMachine {
392392 Ok ( transitions)
393393 }
394394
395+
396+ fn get_label_for_return_code ( cb_return_code : & u8 ) -> String {
397+ if cb_return_code == & Transition :: TRANSITION_CALLBACK_SUCCESS {
398+ "transition_success" . into ( )
399+ } else if cb_return_code == & Transition :: TRANSITION_CALLBACK_FAILURE {
400+ "transition_failure" . into ( )
401+ } else {
402+ "transition_error" . into ( )
403+ }
404+ }
405+
395406 pub ( crate ) fn change_state ( & self , transition_id : u8 ) -> Result < u8 , RclrsError > {
396407 // Make sure that the state machine is initialized before doing anything
397408 let mut state_machine = self . state_machine . lock ( ) . unwrap ( ) ;
@@ -419,26 +430,16 @@ impl LifecycleMachine {
419430 . ok ( ) ?
420431 } ;
421432
422- let get_label_for_return_code = |cb_return_code : & u8 | {
423- if cb_return_code == & Transition :: TRANSITION_CALLBACK_SUCCESS {
424- "transition_success"
425- } else if cb_return_code == & Transition :: TRANSITION_CALLBACK_FAILURE {
426- "transition_failure"
427- } else {
428- "transition_error"
429- }
430- } ;
431-
432433 // SAFETY: The state machine is not null, since it's initialized
433434 let cb_return_code =
434435 self . execute_callback ( unsafe { ( * state_machine. current_state ) . id } , initial_state) ;
435- let transition_label = get_label_for_return_code ( & cb_return_code) ;
436+ let transition_label = Self :: get_label_for_return_code ( & cb_return_code) ;
436437 let transition_label_cstr = CString :: new ( transition_label) . unwrap ( ) ; // Should be fine, since the strings are known to be valid CStrings
437438
438439 // SAFETY: The state machine is not null, since it's initialized
439440 unsafe {
440441 rcl_lifecycle_trigger_transition_by_label (
441- & mut * state_machine as * mut rcl_lifecycle_state_machine_s ,
442+ & mut * state_machine,
442443 transition_label_cstr. as_ptr ( ) ,
443444 publish_update,
444445 )
0 commit comments