Struct all_is_cubes::behavior::BehaviorContext
source · #[non_exhaustive]pub struct BehaviorContext<'a, H: BehaviorHost> {
pub tick: Tick,
pub host: &'a H,
pub attachment: &'a H::Attachment,
/* private fields */
}Expand description
Items available to a Behavior during Behavior::step().
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.tick: TickThe time tick that is currently passing, causing this step.
host: &'a HThe current state of the behavior’s host object.
attachment: &'a H::AttachmentAdditional data about “where” the behavior is attached to the host; what part of the host should be affected by the behavior.
Implementations§
source§impl<'a, H: BehaviorHost> BehaviorContext<'a, H>
impl<'a, H: BehaviorHost> BehaviorContext<'a, H>
sourcepub fn waker(&self) -> &'a BehaviorWaker
pub fn waker(&self) -> &'a BehaviorWaker
Returns a waker that should be used to signal when the behavior’s
step() should be called again, in the case where it
returns Then::Sleep.
This is precisely analogous to the use of Waker with Future::poll();
see the comment on BehaviorWaker for the rationale for not being a Waker.
sourcepub fn bind_host(&self, transaction: H::Transaction) -> UniverseTransaction
pub fn bind_host(&self, transaction: H::Transaction) -> UniverseTransaction
Take a transaction applicable to the behavior’s host, and wrap it to become a
UniverseTransaction for the host’s containing universe.
sourcepub fn replace_self<B: Behavior<H> + 'static>(
&self,
new_behavior: B,
) -> UniverseTransaction
pub fn replace_self<B: Behavior<H> + 'static>( &self, new_behavior: B, ) -> UniverseTransaction
Returns a transaction which will replace this behavior with a new value.
This should be used whenever a behavior wishes to modify itself, to ensure that the modification only takes effect when the behavior’s other effects do.
Trait Implementations§
Auto Trait Implementations§
impl<'a, H> Freeze for BehaviorContext<'a, H>
impl<'a, H> !RefUnwindSafe for BehaviorContext<'a, H>
impl<'a, H> !Send for BehaviorContext<'a, H>
impl<'a, H> !Sync for BehaviorContext<'a, H>
impl<'a, H> Unpin for BehaviorContext<'a, H>
impl<'a, H> !UnwindSafe for BehaviorContext<'a, H>
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> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
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>. Box<dyn Any> can
then be further downcast into Box<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>. Rc<Any> 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> 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 more