@@ -12,7 +12,7 @@ use crate::meta;
12
12
use crate :: meta:: InParamTuple ;
13
13
use crate :: obj:: { bounds, Bounds , Gd , GodotClass , WithSignals } ;
14
14
use crate :: registry:: signal:: signal_receiver:: { IndirectSignalReceiver , SignalReceiver } ;
15
- use crate :: registry:: signal:: { ToSignalObj , TypedSignal } ;
15
+ use crate :: registry:: signal:: { ConnectHandle , ToSignalObj , TypedSignal } ;
16
16
17
17
/// Builder for customizing signal connections.
18
18
///
@@ -125,15 +125,15 @@ where
125
125
fn inner_connect_godot_fn < F > (
126
126
self ,
127
127
godot_fn : impl FnMut ( & [ & Variant ] ) -> Result < Variant , ( ) > + ' static ,
128
- ) {
128
+ ) -> ConnectHandle {
129
129
let callable_name = match & self . data . callable_name {
130
130
Some ( user_provided_name) => user_provided_name,
131
131
None => & make_callable_name :: < F > ( ) ,
132
132
} ;
133
133
134
134
let callable = Callable :: from_local_fn ( callable_name, godot_fn) ;
135
135
self . parent_sig
136
- . inner_connect_untyped ( & callable, self . data . connect_flags ) ;
136
+ . inner_connect_untyped ( callable, self . data . connect_flags )
137
137
}
138
138
}
139
139
@@ -154,7 +154,7 @@ impl<C: WithSignals, Ps: InParamTuple + 'static> ConnectBuilder<'_, '_, C, Ps> {
154
154
/// [`connect_other_gd()`][Self::connect_other_gd].
155
155
/// - If you need [`connect flags`](ConnectFlags), call [`flags()`](Self::flags) before this.
156
156
/// - If you need cross-thread signals, use [`connect_sync()`](#method.connect_sync) instead (requires feature "experimental-threads").
157
- pub fn connect < F > ( self , mut function : F )
157
+ pub fn connect < F > ( self , mut function : F ) -> ConnectHandle
158
158
where
159
159
for < ' c_rcv > F : SignalReceiver < ( ) , Ps > ,
160
160
for < ' c_rcv > IndirectSignalReceiver < ' c_rcv , ( ) , Ps , F > : From < & ' c_rcv mut F > ,
@@ -165,7 +165,7 @@ impl<C: WithSignals, Ps: InParamTuple + 'static> ConnectBuilder<'_, '_, C, Ps> {
165
165
. call ( ( ) , args) ;
166
166
} ) ;
167
167
168
- self . inner_connect_godot_fn :: < F > ( godot_fn) ;
168
+ self . inner_connect_godot_fn :: < F > ( godot_fn)
169
169
}
170
170
171
171
/// Connect a method with `&mut self` as the first parameter (user classes only).
@@ -176,7 +176,7 @@ impl<C: WithSignals, Ps: InParamTuple + 'static> ConnectBuilder<'_, '_, C, Ps> {
176
176
/// - To connect to methods on other objects, use [`connect_other_mut()`][Self::connect_other_mut].
177
177
/// - If you need [connect flags](ConnectFlags), call [`flags()`](Self::flags) before this.
178
178
/// - If you need cross-thread signals, use [`connect_sync()`](#method.connect_sync) instead (requires feature `experimental-threads`).
179
- pub fn connect_self_mut < F > ( self , mut function : F )
179
+ pub fn connect_self_mut < F > ( self , mut function : F ) -> ConnectHandle
180
180
where
181
181
C : Bounds < Declarer = bounds:: DeclUser > ,
182
182
for < ' c_rcv > F : SignalReceiver < & ' c_rcv mut C , Ps > ,
@@ -191,7 +191,7 @@ impl<C: WithSignals, Ps: InParamTuple + 'static> ConnectBuilder<'_, '_, C, Ps> {
191
191
. call ( & mut * guard, args) ;
192
192
} ) ;
193
193
194
- self . inner_connect_godot_fn :: < F > ( godot_fn) ;
194
+ self . inner_connect_godot_fn :: < F > ( godot_fn)
195
195
}
196
196
197
197
/// Connect a method with `&mut Gd<Self>` as the first parameter (user + engine classes).
@@ -202,7 +202,7 @@ impl<C: WithSignals, Ps: InParamTuple + 'static> ConnectBuilder<'_, '_, C, Ps> {
202
202
/// - To connect to methods on other objects, use [`connect_other_gd()`][Self::connect_other_gd].
203
203
/// - If you need [connect flags](ConnectFlags), call [`flags()`](Self::flags) before this.
204
204
/// - If you need cross-thread signals, use [`connect_sync()`](#method.connect_sync) instead (requires feature `experimental-threads`).
205
- pub fn connect_self_gd < F > ( self , mut function : F )
205
+ pub fn connect_self_gd < F > ( self , mut function : F ) -> ConnectHandle
206
206
where
207
207
F : SignalReceiver < Gd < C > , Ps > ,
208
208
for < ' c_rcv > IndirectSignalReceiver < ' c_rcv , Gd < C > , Ps , F > : From < & ' c_rcv mut F > ,
@@ -215,7 +215,7 @@ impl<C: WithSignals, Ps: InParamTuple + 'static> ConnectBuilder<'_, '_, C, Ps> {
215
215
. call ( gd. clone ( ) , args) ;
216
216
} ) ;
217
217
218
- self . inner_connect_godot_fn :: < F > ( godot_fn) ;
218
+ self . inner_connect_godot_fn :: < F > ( godot_fn)
219
219
}
220
220
221
221
/// Connect a method with any `&mut OtherC` as the first parameter (user classes only).
@@ -231,7 +231,11 @@ impl<C: WithSignals, Ps: InParamTuple + 'static> ConnectBuilder<'_, '_, C, Ps> {
231
231
/// - To connect to methods on the object that owns this signal, use [`connect_self_mut()`][Self::connect_self_mut].
232
232
/// - If you need [connect flags](ConnectFlags), call [`flags()`](Self::flags) before this.
233
233
/// - If you need cross-thread signals, use [`connect_sync()`](#method.connect_sync) instead (requires feature "experimental-threads").
234
- pub fn connect_other_mut < F , OtherC > ( self , object : & impl ToSignalObj < OtherC > , mut method : F )
234
+ pub fn connect_other_mut < F , OtherC > (
235
+ self ,
236
+ object : & impl ToSignalObj < OtherC > ,
237
+ mut method : F ,
238
+ ) -> ConnectHandle
235
239
where
236
240
OtherC : GodotClass + Bounds < Declarer = bounds:: DeclUser > ,
237
241
for < ' c_rcv > F : SignalReceiver < & ' c_rcv mut OtherC , Ps > ,
@@ -246,7 +250,7 @@ impl<C: WithSignals, Ps: InParamTuple + 'static> ConnectBuilder<'_, '_, C, Ps> {
246
250
. call ( & mut * guard, args) ;
247
251
} ) ;
248
252
249
- self . inner_connect_godot_fn :: < F > ( godot_fn) ;
253
+ self . inner_connect_godot_fn :: < F > ( godot_fn)
250
254
}
251
255
252
256
/// Connect a method with any `&mut Gd<OtherC>` as the first parameter (user + engine classes).
@@ -260,7 +264,11 @@ impl<C: WithSignals, Ps: InParamTuple + 'static> ConnectBuilder<'_, '_, C, Ps> {
260
264
/// - To connect to methods on the object that owns this signal, use [`connect_self_gd()`][Self::connect_self_gd].
261
265
/// - If you need [connect flags](ConnectFlags), call [`flags()`](Self::flags) before this.
262
266
/// - If you need cross-thread signals, use [`connect_sync()`](#method.connect_sync) instead (requires feature "experimental-threads").
263
- pub fn connect_other_gd < F , OtherC > ( self , object : & impl ToSignalObj < OtherC > , mut method : F )
267
+ pub fn connect_other_gd < F , OtherC > (
268
+ self ,
269
+ object : & impl ToSignalObj < OtherC > ,
270
+ mut method : F ,
271
+ ) -> ConnectHandle
264
272
where
265
273
OtherC : GodotClass ,
266
274
F : SignalReceiver < Gd < OtherC > , Ps > ,
@@ -274,7 +282,7 @@ impl<C: WithSignals, Ps: InParamTuple + 'static> ConnectBuilder<'_, '_, C, Ps> {
274
282
. call ( gd. clone ( ) , args) ;
275
283
} ) ;
276
284
277
- self . inner_connect_godot_fn :: < F > ( godot_fn) ;
285
+ self . inner_connect_godot_fn :: < F > ( godot_fn)
278
286
}
279
287
280
288
/// Connect to this signal using a thread-safe function, allows the signal to be called across threads.
@@ -304,6 +312,6 @@ impl<C: WithSignals, Ps: InParamTuple + 'static> ConnectBuilder<'_, '_, C, Ps> {
304
312
305
313
let callable = Callable :: from_sync_fn ( callable_name, godot_fn) ;
306
314
self . parent_sig
307
- . inner_connect_untyped ( & callable, self . data . connect_flags ) ;
315
+ . inner_connect_untyped ( callable, self . data . connect_flags ) ;
308
316
}
309
317
}
0 commit comments