diff --git a/src/ffi/mod.rs b/src/ffi/mod.rs index dd5ee15d4dd7174dd70897fa897b263157a6ee59..f8901415933fa689dfb5715d11935f6f7b33e79f 100644 --- a/src/ffi/mod.rs +++ b/src/ffi/mod.rs @@ -168,6 +168,14 @@ pub unsafe extern "C" fn connector_new_logging_with_id( } } #[no_mangle] +pub unsafe extern "C" fn connector_new_with_id( + pd: &Arc, + connector_id: ConnectorId, +) -> *mut Connector { + let c = Connector::new(Box::new(DummyLogger), pd.clone(), connector_id); + Box::into_raw(Box::new(c)) +} +#[no_mangle] pub unsafe extern "C" fn connector_new_logging( pd: &Arc, path_ptr: *const u8, @@ -176,17 +184,11 @@ pub unsafe extern "C" fn connector_new_logging( connector_new_logging_with_id(pd, path_ptr, path_len, Connector::random_id()) } -#[no_mangle] -pub unsafe extern "C" fn connector_print_debug(connector: &mut Connector) { - println!("Debug print dump {:#?}", connector); -} - /// Initializes `out` with a new connector using the given protocol description as its configuration. /// The connector uses the given (internal) connector ID. #[no_mangle] pub unsafe extern "C" fn connector_new(pd: &Arc) -> *mut Connector { - let c = Connector::new(Box::new(DummyLogger), pd.clone(), Connector::random_id()); - Box::into_raw(Box::new(c)) + connector_new_with_id(pd, Connector::random_id()) } /// Destroys the given a pointer to the connector on the heap, freeing its resources. @@ -196,6 +198,11 @@ pub unsafe extern "C" fn connector_destroy(connector: *mut Connector) { drop(Box::from_raw(connector)) } +#[no_mangle] +pub unsafe extern "C" fn connector_print_debug(connector: &mut Connector) { + println!("Debug print dump {:#?}", connector); +} + /// Given an initialized connector in setup or connecting state, /// - Creates a new directed port pair with logical channel putter->getter, /// - adds the ports to the native component's interface,