@@ -80,17 +80,22 @@ impl fmt::Debug for Node {
80
80
81
81
impl Node {
82
82
/// Creates a new node in the empty namespace.
83
+ <<<<<<< HEAD
83
84
///
84
85
/// See [`Node::new_with_namespace`] for documentation.
86
+ =======
87
+ #[ deprecated ( since = "0.2.0" , note = "please use `NodeBuilder` instead" ) ]
88
+ >>>>>>> Replace constructor method procedure
85
89
#[ allow ( clippy:: new_ret_no_self ) ]
86
90
pub fn new ( node_name : & str , context : & Context ) -> Result < Node , RclReturnCode > {
87
- Self :: new_with_namespace ( "" , node_name, context)
91
+ NodeBuilder :: new ( node_name , context ) . build ( )
88
92
}
89
93
90
94
/// Creates a new node in a namespace.
91
95
///
92
96
/// A namespace without a leading forward slash is automatically changed to have a leading
93
97
/// forward slash.
98
+ <<<<<<< HEAD
94
99
///
95
100
/// # Naming
96
101
/// The node namespace will be prefixed to the node name itself to form the *fully qualified
@@ -138,42 +143,17 @@ impl Node {
138
143
/// [1]: https://docs.ros.org/en/rolling/How-To-Guides/Node-arguments.html
139
144
/// [2]: https://docs.ros2.org/latest/api/rmw/validate__namespace_8h.html
140
145
/// [3]: https://docs.ros2.org/latest/api/rmw/validate__node__name_8h.html
146
+ =======
147
+ #[ deprecated( since = "0 . 2 . 0 ", note = "please use `NodeBuilder ` instead") ]
148
+ >>>>>>> Replace constructor method procedure
141
149
pub fn new_with_namespace(
142
150
node_ns: & str ,
143
151
node_name: & str ,
144
152
context: & Context ,
145
153
) -> Result <Node , RclReturnCode > {
146
- let raw_node_name = CString :: new ( node_name) . unwrap ( ) ;
147
- let raw_node_ns = CString :: new ( node_ns) . unwrap ( ) ;
148
-
149
- // SAFETY: Getting a zero-initialized value is always safe.
150
- let mut node_handle = unsafe { rcl_get_zero_initialized_node ( ) } ;
151
- let context_handle = & mut * context. handle . lock ( ) ;
152
-
153
- unsafe {
154
- // SAFETY: No preconditions for this function.
155
- let node_options = rcl_node_get_default_options ( ) ;
156
- // SAFETY: The node handle is zero-initialized as expected by this function.
157
- // The strings and node options are copied by this function, so we don't need
158
- // to keep them alive.
159
- // The context handle is kept alive because it is co-owned by the node.
160
- rcl_node_init (
161
- & mut node_handle,
162
- raw_node_name. as_ptr ( ) ,
163
- raw_node_ns. as_ptr ( ) ,
164
- context_handle,
165
- & node_options,
166
- )
167
- . ok ( ) ?;
168
- }
169
-
170
- let handle = Arc :: new ( Mutex :: new ( node_handle) ) ;
171
-
172
- Ok ( Node {
173
- handle,
174
- context : context. handle . clone ( ) ,
175
- subscriptions : std:: vec![ ] ,
176
- } )
154
+ NodeBuilder :: new ( node_name , context )
155
+ . namespace( node_ns )
156
+ . build( )
177
157
}
178
158
179
159
/// Returns the name of the node.
0 commit comments