Struct Signal

Source
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

Signal (stable)

Implementations§

Source§

impl Signal

Source

pub fn from_object_signal<T, S>(object: &Gd<T>, signal_name: S) -> Signal
where T: GodotClass, S: AsArg<StringName>,

Create a signal for the signal object::signal_name.

Godot equivalent: Signal(Object object, StringName signal)

Source

pub fn invalid() -> Signal

Creates an invalid/empty signal that cannot be called.

Godot equivalent: Signal()

Source

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().

Source

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.

Source

pub fn emit(&self, varargs: &[Variant])

Emits this signal.

All Callables connected to this signal will be triggered.

Source

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 this Signal;
  • callable is a reference to the connected Callable;
  • flags is a combination of ConnectFlags.

Godot equivalent: get_connections

Source

pub fn name(&self) -> StringName

Returns the name of the signal.

Source

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

Source

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

Source

pub fn is_connected(&self, callable: &Callable) -> bool

Returns true if the specified Callable is connected to this signal.

Source

pub fn is_null(&self) -> bool

Returns true if the signal’s name does not exist in its object, or the object is not valid.

Source§

impl Signal

Source

pub fn to_fallible_future<R>(&self) -> FallibleSignalFuture<R>

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.

Source

pub fn to_future<R>(&self) -> SignalFuture<R>

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§

Source§

impl Clone for Signal

Source§

fn clone(&self) -> Signal

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Signal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for Signal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Drop for Signal

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl FromGodot for Signal

Source§

fn try_from_godot( via: <Signal as GodotConvert>::Via, ) -> Result<Signal, ConvertError>

Converts the Godot representation to this type, returning Err on failure.
Source§

fn from_godot(via: Self::Via) -> Self

⚠️ Converts the Godot representation to this type. Read more
Source§

fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>

Performs the conversion from a Variant, returning Err on failure.
Source§

fn from_variant(variant: &Variant) -> Self

⚠️ Performs the conversion from a Variant. Read more
Source§

impl GodotConvert for Signal

Source§

type Via = Signal

The type through which Self is represented in Godot.
Source§

impl IntoDynamicSend for Signal

Source§

impl ParamType for Signal

Source§

type ArgPassing = ByRef

Source§

fn owned_to_arg(self) -> impl AsArg<Self>

👎Deprecated since 0.3.2: This method is no longer needed and will be removed in 0.4
Source§

impl PartialEq for Signal

Source§

fn eq(&self, other: &Signal) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToGodot for Signal

Source§

type ToVia<'v> = <Signal as GodotConvert>::Via

Target type of to_godot(), which can differ from Via for pass-by-reference types. Read more
Source§

fn to_godot(&self) -> <Signal as ToGodot>::ToVia<'_>

Converts this type to the Godot type by reference, usually by cloning.
Source§

fn to_variant(&self) -> Variant

Converts this type to a Variant.
Source§

impl Var for Signal

Source§

fn get_property(&self) -> <Signal as GodotConvert>::Via

Source§

fn set_property(&mut self, value: <Signal as GodotConvert>::Via)

Source§

fn var_hint() -> PropertyHintInfo

Specific property hints, only override if they deviate from GodotType::property_info, e.g. for enums/newtypes.
Source§

impl ArrayElement for Signal

Source§

impl GodotType for Signal

Auto Trait Implementations§

§

impl Freeze for Signal

§

impl RefUnwindSafe for Signal

§

impl !Send for Signal

§

impl !Sync for Signal

§

impl Unpin for Signal

§

impl UnwindSafe for Signal

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.