@@ -164,16 +164,16 @@ pub struct Activity {
164164}
165165
166166impl Activity {
167+ #[ allow( unused) ]
167168 pub ( crate ) unsafe fn from_raw ( handle : NonNull < BNActivity > ) -> Self {
168169 Self { handle }
169170 }
170-
171- #[ allow( unused) ]
171+
172172 pub ( crate ) unsafe fn ref_from_raw ( handle : NonNull < BNActivity > ) -> Ref < Self > {
173173 Ref :: new ( Self { handle } )
174174 }
175175
176- pub fn new < S : BnStrCompatible > ( config : S ) -> Self {
176+ pub fn new < S : BnStrCompatible > ( config : S ) -> Ref < Self > {
177177 unsafe extern "C" fn cb_action_nop ( _: * mut c_void , _: * mut BNAnalysisContext ) { }
178178 let config = config. into_bytes_with_nul ( ) ;
179179 let result = unsafe {
@@ -183,10 +183,10 @@ impl Activity {
183183 Some ( cb_action_nop) ,
184184 )
185185 } ;
186- unsafe { Activity :: from_raw ( NonNull :: new ( result) . unwrap ( ) ) }
186+ unsafe { Activity :: ref_from_raw ( NonNull :: new ( result) . unwrap ( ) ) }
187187 }
188188
189- pub fn new_with_action < S , F > ( config : S , mut action : F ) -> Self
189+ pub fn new_with_action < S , F > ( config : S , mut action : F ) -> Ref < Self >
190190 where
191191 S : BnStrCompatible ,
192192 F : FnMut ( & AnalysisContext ) ,
@@ -208,7 +208,7 @@ impl Activity {
208208 Some ( cb_action :: < F > ) ,
209209 )
210210 } ;
211- unsafe { Activity :: from_raw ( NonNull :: new ( result) . unwrap ( ) ) }
211+ unsafe { Activity :: ref_from_raw ( NonNull :: new ( result) . unwrap ( ) ) }
212212 }
213213
214214 pub fn name ( & self ) -> BnString {
@@ -256,35 +256,35 @@ impl Workflow {
256256
257257 /// Create a new unregistered [Workflow] with no activities.
258258 ///
259- /// To get a copy of an existing registered [Workflow] use [Workflow::clone ].
260- pub fn new < S : BnStrCompatible > ( name : S ) -> Self {
259+ /// To get a copy of an existing registered [Workflow] use [Workflow::clone_to ].
260+ pub fn new < S : BnStrCompatible > ( name : S ) -> Ref < Self > {
261261 let name = name. into_bytes_with_nul ( ) ;
262262 let result = unsafe { BNCreateWorkflow ( name. as_ref ( ) . as_ptr ( ) as * const c_char ) } ;
263- unsafe { Workflow :: from_raw ( NonNull :: new ( result) . unwrap ( ) ) }
263+ unsafe { Workflow :: ref_from_raw ( NonNull :: new ( result) . unwrap ( ) ) }
264264 }
265265
266266 /// Make a new unregistered [Workflow], copying all activities and the execution strategy.
267267 ///
268268 /// * `name` - the name for the new [Workflow]
269269 #[ must_use]
270- pub fn clone < S : BnStrCompatible + Clone > ( & self , name : S ) -> Workflow {
271- self . clone_with_root ( name, "" )
270+ pub fn clone_to < S : BnStrCompatible + Clone > ( & self , name : S ) -> Ref < Workflow > {
271+ self . clone_to_with_root ( name, "" )
272272 }
273273
274274 /// Make a new unregistered [Workflow], copying all activities, within `root_activity`, and the execution strategy.
275275 ///
276276 /// * `name` - the name for the new [Workflow]
277277 /// * `root_activity` - perform the clone operation with this activity as the root
278278 #[ must_use]
279- pub fn clone_with_root < S : BnStrCompatible , A : BnStrCompatible > (
279+ pub fn clone_to_with_root < S : BnStrCompatible , A : BnStrCompatible > (
280280 & self ,
281281 name : S ,
282282 root_activity : A ,
283- ) -> Workflow {
283+ ) -> Ref < Workflow > {
284284 let raw_name = name. into_bytes_with_nul ( ) ;
285285 let activity = root_activity. into_bytes_with_nul ( ) ;
286286 unsafe {
287- Self :: from_raw (
287+ Self :: ref_from_raw (
288288 NonNull :: new ( BNWorkflowClone (
289289 self . handle . as_ptr ( ) ,
290290 raw_name. as_ref ( ) . as_ptr ( ) as * const c_char ,
@@ -295,11 +295,11 @@ impl Workflow {
295295 }
296296 }
297297
298- pub fn instance < S : BnStrCompatible > ( name : S ) -> Workflow {
298+ pub fn instance < S : BnStrCompatible > ( name : S ) -> Ref < Workflow > {
299299 let result = unsafe {
300300 BNWorkflowInstance ( name. into_bytes_with_nul ( ) . as_ref ( ) . as_ptr ( ) as * const c_char )
301301 } ;
302- unsafe { Workflow :: from_raw ( NonNull :: new ( result) . unwrap ( ) ) }
302+ unsafe { Workflow :: ref_from_raw ( NonNull :: new ( result) . unwrap ( ) ) }
303303 }
304304
305305 /// List of all registered [Workflow]'s
@@ -341,7 +341,7 @@ impl Workflow {
341341 /// Register an [Activity] with this Workflow.
342342 ///
343343 /// * `activity` - the [Activity] to register
344- pub fn register_activity ( & self , activity : & Activity ) -> Result < Activity , ( ) > {
344+ pub fn register_activity ( & self , activity : & Activity ) -> Result < Ref < Activity > , ( ) > {
345345 self . register_activity_with_subactivities :: < Vec < String > > ( activity, vec ! [ ] )
346346 }
347347
@@ -353,7 +353,7 @@ impl Workflow {
353353 & self ,
354354 activity : & Activity ,
355355 subactivities : I ,
356- ) -> Result < Activity , ( ) >
356+ ) -> Result < Ref < Activity > , ( ) >
357357 where
358358 I : IntoIterator ,
359359 I :: Item : BnStrCompatible ,
@@ -375,7 +375,7 @@ impl Workflow {
375375 )
376376 } ;
377377 let activity_ptr = NonNull :: new ( result) . ok_or ( ( ) ) ?;
378- unsafe { Ok ( Activity :: from_raw ( activity_ptr) ) }
378+ unsafe { Ok ( Activity :: ref_from_raw ( activity_ptr) ) }
379379 }
380380
381381 /// Determine if an Activity exists in this [Workflow].
@@ -418,15 +418,15 @@ impl Workflow {
418418 }
419419
420420 /// Retrieve the Activity object for the specified `name`.
421- pub fn activity < A : BnStrCompatible > ( & self , name : A ) -> Option < Activity > {
421+ pub fn activity < A : BnStrCompatible > ( & self , name : A ) -> Option < Ref < Activity > > {
422422 let name = name. into_bytes_with_nul ( ) ;
423423 let result = unsafe {
424424 BNWorkflowGetActivity (
425425 self . handle . as_ptr ( ) ,
426426 name. as_ref ( ) . as_ptr ( ) as * const c_char ,
427427 )
428428 } ;
429- NonNull :: new ( result) . map ( |a| unsafe { Activity :: from_raw ( a) } )
429+ NonNull :: new ( result) . map ( |a| unsafe { Activity :: ref_from_raw ( a) } )
430430 }
431431
432432 /// Retrieve the list of activity roots for the [Workflow], or if
0 commit comments