godot::builtin

Struct Signal

pub struct Signal { /* private fields */ }
Expand description

A Signal represents a signal of an Object instance in Godot.

Signals are composed of a reference to an Object and the name of the signal on this object.

§Godot docs

Signal (stable)

Implementations§

§

impl Signal

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

Create a signal for the signal object::signal_name.

Godot equivalent: Signal(Object object, StringName 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

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, use Self::is_connected first to check for existing connections.

pub fn disconnect(&self, callable: Callable)

Disconnects this signal from the specified Callable.

If the connection does not exist, generates an error. Use Self::is_connected to make sure that the connection exists.

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

Emits this signal.

All Callables connected to this signal will be triggered.

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

pub fn name(&self) -> StringName

Returns the name of the signal.

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.

Godot equivalent: get_object

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.

Godot equivalent: get_object_id

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

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

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.

Trait Implementations§

§

impl ArrayElement for Signal

§

impl Clone for Signal

§

fn clone(&self) -> Signal

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
§

impl Debug for Signal

§

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

Formats the value using the given formatter. Read more
§

impl Display for Signal

§

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

Formats the value using the given formatter. Read more
§

impl Drop for Signal

§

fn drop(&mut self)

Executes the destructor for this type. Read more
§

impl FromGodot for Signal

§

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

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

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

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

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

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

fn from_variant(variant: &Variant) -> Self

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

impl GodotConvert for Signal

§

type Via = Signal

The type through which Self is represented in Godot.
§

impl PartialEq for Signal

§

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.
§

impl ToGodot for Signal

§

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

Target type of to_godot(), which differs from Via for pass-by-reference types.
§

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

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

fn to_variant(&self) -> Variant

Converts this type to a Variant.
§

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

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

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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§

default 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.