pub struct ActorId(/* private fields */);Expand description
Unique identifier for a registered actor.
Returned by Supervisor::add_actor. Use ActorId to:
- Identify actors in event metadata (sender information)
- Reference actors in test harness assertions
- Track event flow between specific actors
ActorId is cheap to clone and safe to serialize. Equality works correctly
across serialization boundaries (uses string comparison with a fast-path
for pointer equality when IDs share the same allocation).
§Example
ⓘ
let producer = sup.add_actor("producer", |ctx| Producer::new(ctx), &[DefaultTopic])?;
let consumer = sup.add_actor("consumer", |ctx| Consumer::new(ctx), &[DefaultTopic])?;
// Use in test harness
let mut test = Harness::new(&mut sup).await;
test.send_as(&producer, MyEvent::Data(42)).await?;
assert!(test.actor(&consumer).events_received() > 0);
// Access sender from event metadata
let sender: &ActorId = envelope.meta().actor_id();§Creating IDs for External Systems
For bridge actors that receive events from external sources (IPC, WebSocket),
use ActorId::new() to create identifiers for those sources.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ActorId
impl<'de> Deserialize<'de> for ActorId
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for ActorId
impl Ord for ActorId
Source§impl PartialOrd for ActorId
impl PartialOrd for ActorId
impl Eq for ActorId
Auto Trait Implementations§
impl Freeze for ActorId
impl RefUnwindSafe for ActorId
impl Send for ActorId
impl Sync for ActorId
impl Unpin for ActorId
impl UnsafeUnpin for ActorId
impl UnwindSafe for ActorId
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
Mutably borrows from an owned value. Read more