@@ -64,51 +64,25 @@ pub struct NodeBuilder<'a> {
64
64
65
65
impl Node {
66
66
/// Creates a new node in the empty namespace.
67
+ #[ deprecated( since = "0.2.0" , note = "please use `NodeBuilder` instead" ) ]
67
68
#[ allow( clippy:: new_ret_no_self) ]
68
69
pub fn new ( node_name : & str , context : & Context ) -> Result < Node , RclReturnCode > {
69
- Self :: new_with_namespace ( "" , node_name, context)
70
+ NodeBuilder :: new ( node_name, context) . build ( )
70
71
}
71
72
72
73
/// Creates a new node in a namespace.
73
74
///
74
75
/// A namespace without a leading forward slash is automatically changed to have a leading
75
76
/// forward slash.
77
+ #[ deprecated( since = "0.2.0" , note = "please use `NodeBuilder` instead" ) ]
76
78
pub fn new_with_namespace (
77
79
node_ns : & str ,
78
80
node_name : & str ,
79
81
context : & Context ,
80
82
) -> Result < Node , RclReturnCode > {
81
- let raw_node_name = CString :: new ( node_name) . unwrap ( ) ;
82
- let raw_node_ns = CString :: new ( node_ns) . unwrap ( ) ;
83
-
84
- // SAFETY: Getting a zero-initialized value is always safe.
85
- let mut node_handle = unsafe { rcl_get_zero_initialized_node ( ) } ;
86
- let context_handle = & mut * context. handle . lock ( ) ;
87
-
88
- unsafe {
89
- // SAFETY: No preconditions for this function.
90
- let node_options = rcl_node_get_default_options ( ) ;
91
- // SAFETY: The node handle is zero-initialized as expected by this function.
92
- // The strings and node options are copied by this function, so we don't need
93
- // to keep them alive.
94
- // The context handle is kept alive because it is co-owned by the node.
95
- rcl_node_init (
96
- & mut node_handle,
97
- raw_node_name. as_ptr ( ) ,
98
- raw_node_ns. as_ptr ( ) ,
99
- context_handle,
100
- & node_options,
101
- )
102
- . ok ( ) ?;
103
- }
104
-
105
- let handle = Arc :: new ( Mutex :: new ( node_handle) ) ;
106
-
107
- Ok ( Node {
108
- handle,
109
- context : context. handle . clone ( ) ,
110
- subscriptions : std:: vec![ ] ,
111
- } )
83
+ NodeBuilder :: new ( node_name, context)
84
+ . namespace ( node_ns)
85
+ . build ( )
112
86
}
113
87
114
88
/// Returns the name of the node.
0 commit comments