Struct Signal
pub struct Signal { /* private fields */ }
Expand description
Untyped Godot signal.
Signals are composed of a pointer to an Object
and the name of the signal on this object.
In Rust, you might want to work with type-safe signals, available under the TypedSignal
struct.
§Godot docs
Implementations§
§impl Signal
impl Signal
pub fn from_object_signal<T, S>(object: &Gd<T>, signal_name: S) -> Signal
pub fn from_object_signal<T, S>(object: &Gd<T>, signal_name: S) -> Signal
Create a signal for the signal object::signal_name
.
Godot equivalent: Signal(Object object, StringName signal)
pub fn invalid() -> Signal
pub fn invalid() -> Signal
Creates an invalid/empty signal that cannot be called.
Godot equivalent: Signal()
pub fn connect(&self, callable: &Callable, flags: i64) -> Error
pub fn connect(&self, callable: &Callable, flags: i64) -> Error
Connects this signal to the specified callable.
Optional flags can be also added to configure the connection’s behavior (see ConnectFlags
constants).
You can provide additional arguments to the connected callable by using Callable::bind
.
A signal can only be connected once to the same Callable
. If the signal is already connected,
returns Error::ERR_INVALID_PARAMETER
and
pushes an error message, unless the signal is connected with ConnectFlags::REFERENCE_COUNTED
.
To prevent this, check for existing connections with is_connected()
.
pub fn disconnect(&self, callable: &Callable)
pub fn disconnect(&self, callable: &Callable)
Disconnects this signal from the specified Callable
.
If the connection does not exist, generates an error. Use is_connected()
to make sure that the connection exists.
pub fn emit(&self, varargs: &[Variant])
pub fn emit(&self, varargs: &[Variant])
Emits this signal.
All Callables connected to this signal will be triggered.
pub fn connections(&self) -> Array<Dictionary>
pub fn connections(&self) -> Array<Dictionary>
Returns an Array
of connections for this signal.
Each connection is represented as a Dictionary that contains three entries:
signal
is a reference to thisSignal
;callable
is a reference to the connectedCallable
;flags
is a combination ofConnectFlags
.
Godot equivalent: get_connections
pub fn name(&self) -> StringName
pub fn name(&self) -> StringName
Returns the name of the signal.
pub fn object(&self) -> Option<Gd<Object>>
pub fn object(&self) -> Option<Gd<Object>>
Returns the object to which this signal belongs.
Returns None
when this signal doesn’t have any object, or the object is dead. You can differentiate these two situations using
object_id()
.
Godot equivalent: get_object
pub fn object_id(&self) -> Option<InstanceId>
pub fn object_id(&self) -> Option<InstanceId>
Returns the ID of this signal’s object, see also Gd::instance_id
.
Returns None
when this signal doesn’t have any object.
If the pointed-to object is dead, the ID will still be returned. Use object()
to check for liveness.
Godot equivalent: get_object_id
pub fn is_connected(&self, callable: &Callable) -> bool
pub fn is_connected(&self, callable: &Callable) -> bool
Returns true
if the specified Callable
is connected to this signal.
§impl Signal
impl Signal
pub fn to_fallible_future<R>(&self) -> FallibleSignalFuture<R> ⓘwhere
R: InParamTuple + IntoDynamicSend,
pub fn to_fallible_future<R>(&self) -> FallibleSignalFuture<R> ⓘwhere
R: InParamTuple + IntoDynamicSend,
Creates a fallible future for this signal.
The future will resolve the next time the signal is emitted.
See FallibleSignalFuture
for details.
Since the Signal
type does not contain information on the signal argument types, the future output type has to be inferred from
the call to this function.
pub fn to_future<R>(&self) -> SignalFuture<R> ⓘwhere
R: InParamTuple + IntoDynamicSend,
pub fn to_future<R>(&self) -> SignalFuture<R> ⓘwhere
R: InParamTuple + IntoDynamicSend,
Creates a future for this signal.
The future will resolve the next time the signal is emitted, but might panic if the signal object is freed.
See SignalFuture
for details.
Since the Signal
type does not contain information on the signal argument types, the future output type has to be inferred from
the call to this function.
Trait Implementations§
§impl FromGodot for Signal
impl FromGodot for Signal
§fn try_from_godot(
via: <Signal as GodotConvert>::Via,
) -> Result<Signal, ConvertError>
fn try_from_godot( via: <Signal as GodotConvert>::Via, ) -> Result<Signal, ConvertError>
Err
on failure.§fn from_godot(via: Self::Via) -> Self
fn from_godot(via: Self::Via) -> Self
§fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
Variant
, returning Err
on failure.§fn from_variant(variant: &Variant) -> Self
fn from_variant(variant: &Variant) -> Self
§impl IntoDynamicSend for Signal
impl IntoDynamicSend for Signal
type Target = ThreadConfined<Signal>
fn into_dynamic_send(self) -> <Signal as IntoDynamicSend>::Target
§impl ParamType for Signal
impl ParamType for Signal
type ArgPassing = ByRef
§fn owned_to_arg(self) -> impl AsArg<Self>
fn owned_to_arg(self) -> impl AsArg<Self>
§impl ToGodot for Signal
impl ToGodot for Signal
§impl Var for Signal
impl Var for Signal
fn get_property(&self) -> <Signal as GodotConvert>::Via
fn set_property(&mut self, value: <Signal as GodotConvert>::Via)
§fn var_hint() -> PropertyHintInfo
fn var_hint() -> PropertyHintInfo
GodotType::property_info
, e.g. for enums/newtypes.