@@ -12,7 +12,7 @@ use crate::meta;
1212use crate :: meta:: InParamTuple ;
1313use crate :: obj:: { bounds, Bounds , Gd , GodotClass , WithSignals } ;
1414use crate :: registry:: signal:: signal_receiver:: { IndirectSignalReceiver , SignalReceiver } ;
15- use crate :: registry:: signal:: { ToSignalObj , TypedSignal } ;
15+ use crate :: registry:: signal:: { ConnectHandle , ToSignalObj , TypedSignal } ;
1616
1717/// Builder for customizing signal connections.
1818///
@@ -125,15 +125,15 @@ where
125125 fn inner_connect_godot_fn < F > (
126126 self ,
127127 godot_fn : impl FnMut ( & [ & Variant ] ) -> Result < Variant , ( ) > + ' static ,
128- ) {
128+ ) -> ConnectHandle {
129129 let callable_name = match & self . data . callable_name {
130130 Some ( user_provided_name) => user_provided_name,
131131 None => & make_callable_name :: < F > ( ) ,
132132 } ;
133133
134134 let callable = Callable :: from_local_fn ( callable_name, godot_fn) ;
135135 self . parent_sig
136- . inner_connect_untyped ( & callable, self . data . connect_flags ) ;
136+ . inner_connect_untyped ( callable, self . data . connect_flags )
137137 }
138138}
139139
@@ -154,7 +154,7 @@ impl<C: WithSignals, Ps: InParamTuple + 'static> ConnectBuilder<'_, '_, C, Ps> {
154154 /// [`connect_other_gd()`][Self::connect_other_gd].
155155 /// - If you need [`connect flags`](ConnectFlags), call [`flags()`](Self::flags) before this.
156156 /// - 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
158158 where
159159 for < ' c_rcv > F : SignalReceiver < ( ) , Ps > ,
160160 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> {
165165 . call ( ( ) , args) ;
166166 } ) ;
167167
168- self . inner_connect_godot_fn :: < F > ( godot_fn) ;
168+ self . inner_connect_godot_fn :: < F > ( godot_fn)
169169 }
170170
171171 /// 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> {
176176 /// - To connect to methods on other objects, use [`connect_other_mut()`][Self::connect_other_mut].
177177 /// - If you need [connect flags](ConnectFlags), call [`flags()`](Self::flags) before this.
178178 /// - 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
180180 where
181181 C : Bounds < Declarer = bounds:: DeclUser > ,
182182 for < ' c_rcv > F : SignalReceiver < & ' c_rcv mut C , Ps > ,
@@ -191,7 +191,7 @@ impl<C: WithSignals, Ps: InParamTuple + 'static> ConnectBuilder<'_, '_, C, Ps> {
191191 . call ( & mut * guard, args) ;
192192 } ) ;
193193
194- self . inner_connect_godot_fn :: < F > ( godot_fn) ;
194+ self . inner_connect_godot_fn :: < F > ( godot_fn)
195195 }
196196
197197 /// 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> {
202202 /// - To connect to methods on other objects, use [`connect_other_gd()`][Self::connect_other_gd].
203203 /// - If you need [connect flags](ConnectFlags), call [`flags()`](Self::flags) before this.
204204 /// - 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
206206 where
207207 F : SignalReceiver < Gd < C > , Ps > ,
208208 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> {
215215 . call ( gd. clone ( ) , args) ;
216216 } ) ;
217217
218- self . inner_connect_godot_fn :: < F > ( godot_fn) ;
218+ self . inner_connect_godot_fn :: < F > ( godot_fn)
219219 }
220220
221221 /// 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> {
231231 /// - To connect to methods on the object that owns this signal, use [`connect_self_mut()`][Self::connect_self_mut].
232232 /// - If you need [connect flags](ConnectFlags), call [`flags()`](Self::flags) before this.
233233 /// - 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
235239 where
236240 OtherC : GodotClass + Bounds < Declarer = bounds:: DeclUser > ,
237241 for < ' c_rcv > F : SignalReceiver < & ' c_rcv mut OtherC , Ps > ,
@@ -246,7 +250,7 @@ impl<C: WithSignals, Ps: InParamTuple + 'static> ConnectBuilder<'_, '_, C, Ps> {
246250 . call ( & mut * guard, args) ;
247251 } ) ;
248252
249- self . inner_connect_godot_fn :: < F > ( godot_fn) ;
253+ self . inner_connect_godot_fn :: < F > ( godot_fn)
250254 }
251255
252256 /// 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> {
260264 /// - To connect to methods on the object that owns this signal, use [`connect_self_gd()`][Self::connect_self_gd].
261265 /// - If you need [connect flags](ConnectFlags), call [`flags()`](Self::flags) before this.
262266 /// - 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
264272 where
265273 OtherC : GodotClass ,
266274 F : SignalReceiver < Gd < OtherC > , Ps > ,
@@ -274,7 +282,7 @@ impl<C: WithSignals, Ps: InParamTuple + 'static> ConnectBuilder<'_, '_, C, Ps> {
274282 . call ( gd. clone ( ) , args) ;
275283 } ) ;
276284
277- self . inner_connect_godot_fn :: < F > ( godot_fn) ;
285+ self . inner_connect_godot_fn :: < F > ( godot_fn)
278286 }
279287
280288 /// 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> {
304312
305313 let callable = Callable :: from_sync_fn ( callable_name, godot_fn) ;
306314 self . parent_sig
307- . inner_connect_untyped ( & callable, self . data . connect_flags ) ;
315+ . inner_connect_untyped ( callable, self . data . connect_flags ) ;
308316 }
309317}
0 commit comments