Crate signals2

source ·
Expand description

signals2

signals2 is a thread-safe signal/slot library inspired by the boost::signals2 C++ library. Signals are objects that contain a list of callback functions (“slots”) to be executed when the signal is “emitted”. Signals and their corresponding slots can be managed through the use of connections and shared connection blocks.

signals2 contains no unsafe code and compiles on stable Rust 1.53.

signals2 is distributed under the Boost Software License, Version 1.0.

Modules

  • Defines the combiner trait and several simple combiners that can be used.
  • Defines different connect traits for signals.
  • Defines different emit traits for signals.

Structs

  • A handle to a signal that allows new slots to be connected to the underlying signal. Useful in cases where it is undesireable to allow unresitriced access to a signal while still allowing new slots to be connected. Internally, a ConnectHandle uses a WeakSignal. If the underlying signal no longer exists, connect will return a connection that is in a disconnected state.
  • A handle to a signal that allows the signal to be emitted. Useful in cases where it is undesireable to allow unresitriced access to a signal while still allowing the signal to be emitted. Internally, an EmitHandle uses a WeakSignal. The result of calling emit on an EmitHandle is an Option<C::Output> where C is the combiner type of the signal. If the underlying signal no longer exists, None is returned.
  • A shared connection block can be used to temporarily block a slot from executing. There can be an arbitrary number of shared connection blocks for any particular slot. If any of the shared connection blocks are blocking the slot, that slot will not be executed when the signal is emitted.
  • A handle to a signal with a slot function signature of Args -> R. C defines the combiner used to generate a return value when emit is envoked. G defines the ordering of groups of slots. Arguments given to the signal must implement Clone. If you need to emit a signal with an argument that doesn’t implement clone, that argument should be wrapped in an Arc<T> (as an example) to make it cloneable.
  • A weak reference to a signal’s slots. Useful for allowing slots to maintain a persistant reference to their owning signal without causing a memory leak.

Enums

  • Represents a group to connect a slot to in a signal.
  • Represents a position to connect a slot to in a group of slots.

Traits

  • Connect trait for signals with slots that accept the corresponding number of arguments.
  • Connect trait for signals with slots that accept the corresponding number of arguments.
  • Connect trait for signals with slots that accept the corresponding number of arguments.
  • Connect trait for signals with slots that accept the corresponding number of arguments.
  • Connect trait for signals with slots that accept the corresponding number of arguments.
  • Connect trait for signals with slots that accept the corresponding number of arguments.
  • Connect trait for signals with slots that accept the corresponding number of arguments.
  • Connect trait for signals with slots that accept the corresponding number of arguments.
  • Connect trait for signals with slots that accept the corresponding number of arguments.
  • Connect trait for signals with slots that accept the corresponding number of arguments.
  • Connect trait for signals with slots that accept the corresponding number of arguments.
  • Connect trait for signals with slots that accept the corresponding number of arguments.
  • Connect trait for signals with slots that accept the corresponding number of arguments.
  • Emit trait for signals with slots that accept the corresponding number of arguments.
  • Emit trait for signals with slots that accept the corresponding number of arguments.
  • Emit trait for signals with slots that accept the corresponding number of arguments.
  • Emit trait for signals with slots that accept the corresponding number of arguments.
  • Emit trait for signals with slots that accept the corresponding number of arguments.
  • Emit trait for signals with slots that accept the corresponding number of arguments.
  • Emit trait for signals with slots that accept the corresponding number of arguments.
  • Emit trait for signals with slots that accept the corresponding number of arguments.
  • Emit trait for signals with slots that accept the corresponding number of arguments.
  • Emit trait for signals with slots that accept the corresponding number of arguments.
  • Emit trait for signals with slots that accept the corresponding number of arguments.
  • Emit trait for signals with slots that accept the corresponding number of arguments.
  • Emit trait for signals with slots that accept the corresponding number of arguments.

Type Definitions

  • A connection manages one slot for one particular signal. Connections carry no type information about their underlying signal. Connections are created when new slots are connected to a signal.
  • Scoped connections are identical to regular connections, except that they will automcatically disconnect themselves when dropped.