pub struct SignalBus { /* private fields */ }Expand description
Double-buffered message service owned by a crate::scene::Scene.
Each buffer is limited independently, so at most twice capacity() events
are retained. Payload sizes are caller-owned; no background/global state exists.
Implementations§
Source§impl SignalBus
impl SignalBus
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates an empty bus. A zero capacity deliberately rejects all sends.
Sourcepub fn send(
&mut self,
channel: &str,
payload: Value,
sender: Option<Entity>,
target: Option<Entity>,
) -> Result<u64, SignalError>
pub fn send( &mut self, channel: &str, payload: Value, sender: Option<Entity>, target: Option<Entity>, ) -> Result<u64, SignalError>
Enqueues a broadcast or directed signal for the next simulation frame. Returns its sequence, or a typed rejection without modifying the bus. The host may address any handle; script helpers validate recipient liveness.
Sourcepub fn begin_frame(&mut self)
pub fn begin_frame(&mut self)
Expires the previous inbox and publishes all pending messages, preserving order. Runtime calls this once before script sync/update, including during single-step.
Sourcepub fn incoming(&self) -> &[Signal]
pub fn incoming(&self) -> &[Signal]
Current delivered snapshot, valid until the next mutable bus operation.
Sourcepub fn channel<'a>(
&'a self,
channel: &'a str,
) -> impl Iterator<Item = &'a Signal>
pub fn channel<'a>( &'a self, channel: &'a str, ) -> impl Iterator<Item = &'a Signal>
Messages on one exact channel, in send order, without consuming them.
Sourcepub fn for_entity(&self, entity: Entity) -> impl Iterator<Item = &Signal>
pub fn for_entity(&self, entity: Entity) -> impl Iterator<Item = &Signal>
Delivered messages visible to one recipient (broadcast plus exact directed target).
Sourcepub fn pending_len(&self) -> usize
pub fn pending_len(&self) -> usize
Pending messages to be delivered at the next frame boundary.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SignalBus
impl RefUnwindSafe for SignalBus
impl Send for SignalBus
impl Sync for SignalBus
impl Unpin for SignalBus
impl UnsafeUnpin for SignalBus
impl UnwindSafe for SignalBus
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeSync for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.