pub struct AgentId { /* private fields */ }Expand description
An agent, together with the world that spawned it.
Entity is an index plus a generation minted per world, so two worlds
hand out the same id for their first agent. Nothing in Entity records
which one it came from, so passing one world’s entity to another was not
refused - it named a real, different agent there, and the call acted on that
one instead. b.pause(a_entity) paused B’s own agent while the caller
believed it had paused A’s, silently.
The provenance has to travel with the id, which is what this is. It cannot
be built outside this module: the only sources are PipelineWorld::spawn_agent
and PipelineWorld::spawn_from_blueprint, so an id always names an agent
in the world that minted it.
A tag component on the agent was tried first and does not work: looking the tag up on the foreign id resolves to the local agent, whose tag naturally matches, so the check passes and guards nothing.
Implementations§
Source§impl AgentId
impl AgentId
Sourcepub fn in_world(world: &World, entity: Entity) -> Self
pub fn in_world(world: &World, entity: Entity) -> Self
Scope a raw entity to the world it came out of.
The reverse of Self::resolve_in, for a system holding a query result
that needs to call something taking an AgentId. Wrapping and then
resolving inside the same world always round-trips; an id built this way
in one world and resolved in another does not, which is the point.
Sourcepub fn resolve_in(self, world: &World) -> Option<Entity>
pub fn resolve_in(self, world: &World) -> Option<Entity>
The entity, if this id belongs to world.
The check any code holding a raw World should make before touching an
agent it was handed. None means the id came from a different world, in
which case its raw entity would name some other agent here - which is
the whole failure this type exists to prevent.
A world with no OwnWorldId resource (a bare test world assembled by
hand) accepts any id: it never minted one, so there is nothing to
disagree with.
Trait Implementations§
impl Copy for AgentId
impl Eq for AgentId
impl StructuralPartialEq for AgentId
Auto Trait Implementations§
impl Freeze for AgentId
impl RefUnwindSafe for AgentId
impl Send for AgentId
impl Sync for AgentId
impl Unpin for AgentId
impl UnsafeUnpin for AgentId
impl UnwindSafe for AgentId
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.