pub struct FlowSleep<M: Send + Sync + 'static = ()> { /* private fields */ }Expand description
A standing reactive-wake policy on a flow entity (docs/effects-spec.md
§13.1). Attach it to a fulfilled flow entity; the plugin’s wake systems do
the rest. See the module docs for the full contract.
Construct via FlowSleep::persistent / FlowSleep::once, optionally
chaining with_args, with_detect,
and dormant.
Implementations§
Source§impl<M: Send + Sync + 'static> FlowSleep<M>
impl<M: Send + Sync + 'static> FlowSleep<M>
Sourcepub fn persistent(condition: impl Into<String>) -> Self
pub fn persistent(condition: impl Into<String>) -> Self
A persistent policy: condition is an ink function name returning a
truthy value when the flow should wake. Re-arms every time the flow
re-parks (§13.1 point 4).
Sourcepub fn once(condition: impl Into<String>) -> Self
pub fn once(condition: impl Into<String>) -> Self
A one-shot policy: fires once on the first condition-true, then the component is removed and the flow reverts to ordinary advancement.
Sourcepub fn latch(condition: impl Into<String>) -> Self
pub fn latch(condition: impl Into<String>) -> Self
A reversible latch policy (issue #1081): wakes on a transition to
true, then re-arms watching for the transition back to false, and
so on indefinitely. See WakeArming::Latch for the full contract.
Sourcepub fn with_args(self, args: Vec<Value>) -> Self
pub fn with_args(self, args: Vec<Value>) -> Self
Pass arguments to the condition function (declaration order). Builder.
Sourcepub fn with_condition_value(self, value: Value) -> Self
pub fn with_condition_value(self, value: Value) -> Self
Attach a dynamically-resolved fn-value token (Value::FnRef/
Closure) as the wake condition — for a host that obtained the
condition dynamically (a global’s current value, a returned callback
token, a bind_brink_query result) rather than naming it statically
via persistent/once.
When set, this takes over both halves of condition resolution:
the attach-time purity gate checks value’s target row
(check_value_condition_purity instead of
check_named_condition_purity), and evaluation invokes the token
directly (call_ink_function_value instead of resolving condition
by path). condition’s string (from persistent/
once) remains only a diagnostic label at that point —
it is never resolved by path while a condition_value is set. Builder.
Sourcepub fn with_detect(self, detect: DetectSummary) -> Self
pub fn with_detect(self, detect: DetectSummary) -> Self
Attach the condition’s dependency DetectSummary (#913), tuning the
re-evaluation cadence. Without this the summary is empty — treated as
all-detect-capable (re-evaluate only on a World change), the right
default for a condition reading only ink World state. A summary whose
bits names external (component) capabilities
that are all change-detection-capable (#913 AND-merge verdict
all-true) gets the §12.5 cheap path (#996): re-evaluated only when one
of those components changed — provided each is registered via
register_capability (an unregistered capability the wake layer cannot
observe must-polls conservatively). A summary with any must-poll bit
re-evaluates every pass. Builder.
Sourcepub fn reads_bookkeeping(self) -> Self
pub fn reads_bookkeeping(self) -> Self
Declare that this condition reads story bookkeeping — a visit
count ({knot}, TURNS_SINCE(-> knot)), a turn count, the turn index
(TURNS(), CHOICE_COUNT()), or RNG state (issue #1146). Builder.
The row-directed wake-dirtying path re-evaluates a condition only when
a cell it reads was actually written, and a condition’s read set comes
from its effect row — which models global cells only
(brink_format::DirectEffects::reads). Bookkeeping reads are invisible
to it, so a condition that depends on one must say so here, or it will
sit parked through the turns that move it. Nothing else needs this: a
condition reading ink globals is covered by its row automatically, and
a condition whose row is missing/opaque already re-evaluates on any
change.
Graduating a reads-bookkeeping row dimension (so this is inferred
rather than declared) is tracked as the follow-up to #1146.
Known tradeoff, not a bug: once a condition declaring this is
evaluated even once, it stays perpetually flagged for re-evaluation
thereafter, even if nothing it actually depends on ever changes again.
Every Evaluate pass notes an unconditional bookkeeping touch in the
changed-cell ledger (the unavoidable &mut BrinkGlobals residue
building a condition’s context takes), and that residue is itself
indistinguishable, to the row-directed path, from a real bookkeeping
write — so a reads_bookkeeping() reader’s own prior evaluation
re-triggers the next one. This is deliberately on the over-report side
of the ledger’s “never under-report” law (module docs,
crate::wake_delta): the cost is a self-sustaining re-evaluation,
never a missed wake.
Sourcepub fn dormant(self) -> Self
pub fn dormant(self) -> Self
Mark this policy dormant (docs/effects-spec.md §13.1 point 6): the
flow is parked at entry and its first turn runs on the first
condition-true. Attach to a freshly fulfilled flow before it has stepped.
Builder.
Sourcepub fn cancel(&mut self)
pub fn cancel(&mut self)
Cancel the policy: its condition is henceforth a permanent false (§13.1 — “cancellation → false”). The flow stays parked and is never re-evaluated or woken by this policy again. To fully detach, remove the component; to change the wake condition, replace it with a new one.
Sourcepub fn condition(&self) -> &str
pub fn condition(&self) -> &str
The ink function name of the wake condition — a diagnostic label only
when condition_value is Some.
Sourcepub fn condition_value(&self) -> Option<&Value>
pub fn condition_value(&self) -> Option<&Value>
The dynamically-resolved fn-value token, if
with_condition_value set one.
Sourcepub fn state(&self) -> SleepState
pub fn state(&self) -> SleepState
The current SleepState.
Sourcepub fn arming(&self) -> WakeArming
pub fn arming(&self) -> WakeArming
The re-arm policy.
Sourcepub fn latch_waiting_for(&self) -> bool
pub fn latch_waiting_for(&self) -> bool
WakeArming::Latch only: the boolean value the condition must next
equal to fire. This doubles as an outside observer’s read of which
side of the latch the policy currently sits on — e.g. for a door
whose condition is “is the switch on?”: true means the policy is
waiting for the switch to turn on (the door is currently locked);
false means it is waiting for the switch to turn off (the door is
currently open). Always true (and unused) for Persistent/Once.
Sourcepub fn dependencies_all_detect_capable(&self) -> bool
pub fn dependencies_all_detect_capable(&self) -> bool
Whether every dependency capability is change-detection-backed (#913
AND-merge verdict). false means the condition polls every pass. true
enables the cheap path: for an empty bits map
(no external dependency) that is re-evaluate-on-BrinkGlobals-change;
for a non-empty one it is re-evaluate-on-watched-component-change (§12.5,
#996), provided each named capability is registered via
register_capability so mark_wake_dirty can observe its ticks — an
unregistered capability the wake layer cannot observe still must-polls.
Sourcepub fn detect_summary(&self) -> &DetectSummary
pub fn detect_summary(&self) -> &DetectSummary
The dependency DetectSummary this policy was built with.
Sourcepub fn declares_bookkeeping_reads(&self) -> bool
pub fn declares_bookkeeping_reads(&self) -> bool
Whether the host declared this condition a reader of story
bookkeeping — see reads_bookkeeping.
Sourcepub fn wants_collect(&self) -> bool
pub fn wants_collect(&self) -> bool
Whether Collect should step this flow this turn — the predicate
advance_batch’s Collect phase applies. Only a
Woken policy admits the flow; a parked, cancelled,
or faulted policy costs zero (skipped).
Trait Implementations§
Source§impl<M: Send + Sync + 'static> Component for FlowSleep<M>
impl<M: Send + Sync + 'static> Component for FlowSleep<M>
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
ComponentRelationshipAccessor required for working with relationships in dynamic contexts. Read moreSource§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreSource§impl<M> FromReflect for FlowSleep<M>
impl<M> FromReflect for FlowSleep<M>
Source§fn from_reflect(reflect: &dyn PartialReflect) -> Option<Self>
fn from_reflect(reflect: &dyn PartialReflect) -> Option<Self>
Self from a reflected value.Source§fn take_from_reflect(
reflect: Box<dyn PartialReflect>,
) -> Result<Self, Box<dyn PartialReflect>>
fn take_from_reflect( reflect: Box<dyn PartialReflect>, ) -> Result<Self, Box<dyn PartialReflect>>
Self using,
constructing the value using from_reflect if that fails. Read moreSource§impl<M> GetTypeRegistration for FlowSleep<M>
impl<M> GetTypeRegistration for FlowSleep<M>
Source§fn get_type_registration() -> TypeRegistration
fn get_type_registration() -> TypeRegistration
TypeRegistration for this type.Source§fn register_type_dependencies(registry: &mut TypeRegistry)
fn register_type_dependencies(registry: &mut TypeRegistry)
Source§impl<M> PartialReflect for FlowSleep<M>
impl<M> PartialReflect for FlowSleep<M>
Source§fn get_represented_type_info(&self) -> Option<&'static TypeInfo>
fn get_represented_type_info(&self) -> Option<&'static TypeInfo>
Source§fn try_apply(&mut self, value: &dyn PartialReflect) -> Result<(), ApplyError>
fn try_apply(&mut self, value: &dyn PartialReflect) -> Result<(), ApplyError>
Source§fn reflect_kind(&self) -> ReflectKind
fn reflect_kind(&self) -> ReflectKind
Source§fn reflect_ref(&self) -> ReflectRef<'_>
fn reflect_ref(&self) -> ReflectRef<'_>
Source§fn reflect_mut(&mut self) -> ReflectMut<'_>
fn reflect_mut(&mut self) -> ReflectMut<'_>
Source§fn reflect_owned(self: Box<Self>) -> ReflectOwned
fn reflect_owned(self: Box<Self>) -> ReflectOwned
Source§fn try_into_reflect(
self: Box<Self>,
) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>
fn try_into_reflect( self: Box<Self>, ) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>
Source§fn try_as_reflect(&self) -> Option<&dyn Reflect>
fn try_as_reflect(&self) -> Option<&dyn Reflect>
Source§fn try_as_reflect_mut(&mut self) -> Option<&mut dyn Reflect>
fn try_as_reflect_mut(&mut self) -> Option<&mut dyn Reflect>
Source§fn into_partial_reflect(self: Box<Self>) -> Box<dyn PartialReflect>
fn into_partial_reflect(self: Box<Self>) -> Box<dyn PartialReflect>
Source§fn as_partial_reflect(&self) -> &dyn PartialReflect
fn as_partial_reflect(&self) -> &dyn PartialReflect
Source§fn as_partial_reflect_mut(&mut self) -> &mut dyn PartialReflect
fn as_partial_reflect_mut(&mut self) -> &mut dyn PartialReflect
Source§fn reflect_partial_eq(&self, value: &dyn PartialReflect) -> Option<bool>
fn reflect_partial_eq(&self, value: &dyn PartialReflect) -> Option<bool>
Source§fn reflect_partial_cmp(&self, value: &dyn PartialReflect) -> Option<Ordering>
fn reflect_partial_cmp(&self, value: &dyn PartialReflect) -> Option<Ordering>
Source§fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>
fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>
Self using reflection. Read moreSource§fn apply(&mut self, value: &(dyn PartialReflect + 'static))
fn apply(&mut self, value: &(dyn PartialReflect + 'static))
Source§fn to_dynamic(&self) -> Box<dyn PartialReflect>
fn to_dynamic(&self) -> Box<dyn PartialReflect>
Source§fn reflect_clone_and_take<T>(&self) -> Result<T, ReflectCloneError>
fn reflect_clone_and_take<T>(&self) -> Result<T, ReflectCloneError>
PartialReflect, combines reflect_clone and
take in a useful fashion, automatically constructing an appropriate
ReflectCloneError if the downcast fails.Source§fn reflect_hash(&self) -> Option<u64>
fn reflect_hash(&self) -> Option<u64>
Source§fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Source§fn is_dynamic(&self) -> bool
fn is_dynamic(&self) -> bool
Source§impl<M> Reflect for FlowSleep<M>
impl<M> Reflect for FlowSleep<M>
Source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
&mut dyn Any. Read moreSource§fn into_reflect(self: Box<Self>) -> Box<dyn Reflect>
fn into_reflect(self: Box<Self>) -> Box<dyn Reflect>
Source§fn as_reflect(&self) -> &dyn Reflect
fn as_reflect(&self) -> &dyn Reflect
Source§fn as_reflect_mut(&mut self) -> &mut dyn Reflect
fn as_reflect_mut(&mut self) -> &mut dyn Reflect
Source§impl<M> Struct for FlowSleep<M>
impl<M> Struct for FlowSleep<M>
Source§fn field(&self, name: &str) -> Option<&dyn PartialReflect>
fn field(&self, name: &str) -> Option<&dyn PartialReflect>
name as a &dyn PartialReflect.Source§fn field_mut(&mut self, name: &str) -> Option<&mut dyn PartialReflect>
fn field_mut(&mut self, name: &str) -> Option<&mut dyn PartialReflect>
name as a
&mut dyn PartialReflect.Source§fn field_at(&self, index: usize) -> Option<&dyn PartialReflect>
fn field_at(&self, index: usize) -> Option<&dyn PartialReflect>
index as a
&dyn PartialReflect.Source§fn field_at_mut(&mut self, index: usize) -> Option<&mut dyn PartialReflect>
fn field_at_mut(&mut self, index: usize) -> Option<&mut dyn PartialReflect>
index
as a &mut dyn PartialReflect.Source§fn index_of_name(&self, name: &str) -> Option<usize>
fn index_of_name(&self, name: &str) -> Option<usize>
Source§fn iter_fields(&self) -> FieldIter<'_> ⓘ
fn iter_fields(&self) -> FieldIter<'_> ⓘ
Source§fn to_dynamic_struct(&self) -> DynamicStruct
fn to_dynamic_struct(&self) -> DynamicStruct
DynamicStruct from this struct.Source§fn get_represented_struct_info(&self) -> Option<&'static StructInfo>
fn get_represented_struct_info(&self) -> Option<&'static StructInfo>
None if TypeInfo is not available.Source§impl<M> TypePath for FlowSleep<M>
impl<M> TypePath for FlowSleep<M>
Source§fn type_path() -> &'static str
fn type_path() -> &'static str
Source§fn short_type_path() -> &'static str
fn short_type_path() -> &'static str
Source§fn type_ident() -> Option<&'static str>
fn type_ident() -> Option<&'static str>
Source§fn crate_name() -> Option<&'static str>
fn crate_name() -> Option<&'static str>
Auto Trait Implementations§
impl<M> Freeze for FlowSleep<M>
impl<M> RefUnwindSafe for FlowSleep<M>
impl<M> Send for FlowSleep<M>
impl<M> Sync for FlowSleep<M>
impl<M> Unpin for FlowSleep<M>
impl<M> UnsafeUnpin for FlowSleep<M>
impl<M> UnwindSafe for FlowSleep<M>
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<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
Source§fn get_component_ids(
components: &Components,
) -> impl Iterator<Item = Option<ComponentId>>
fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>
Source§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
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<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
Source§unsafe fn get_components(
ptr: MovingPtr<'_, C>,
func: &mut impl FnMut(StorageType, OwningPtr<'_>),
) -> <C as DynamicBundle>::Effect
unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect
Source§unsafe fn apply_effect(
_ptr: MovingPtr<'_, MaybeUninit<C>>,
_entity: &mut EntityWorldMut<'_>,
)
unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )
Source§impl<T> DynamicTypePath for Twhere
T: TypePath,
impl<T> DynamicTypePath for Twhere
T: TypePath,
Source§fn reflect_type_path(&self) -> &str
fn reflect_type_path(&self) -> &str
TypePath::type_path.Source§fn reflect_short_type_path(&self) -> &str
fn reflect_short_type_path(&self) -> &str
Source§fn reflect_type_ident(&self) -> Option<&str>
fn reflect_type_ident(&self) -> Option<&str>
TypePath::type_ident.Source§fn reflect_crate_name(&self) -> Option<&str>
fn reflect_crate_name(&self) -> Option<&str>
TypePath::crate_name.Source§fn reflect_module_path(&self) -> Option<&str>
fn reflect_module_path(&self) -> Option<&str>
Source§impl<T> DynamicTyped for Twhere
T: Typed,
impl<T> DynamicTyped for Twhere
T: Typed,
Source§fn reflect_type_info(&self) -> &'static TypeInfo
fn reflect_type_info(&self) -> &'static TypeInfo
Typed::type_info.Source§impl<S> GetField for Swhere
S: Struct,
impl<S> GetField for Swhere
S: Struct,
Source§impl<T> GetPath for T
impl<T> GetPath for T
Source§fn reflect_path<'p>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>
fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>
path. Read moreSource§fn reflect_path_mut<'p>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>
fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>
path. Read moreSource§fn path<'p, T>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&T, ReflectPathError<'p>>where
T: Reflect,
fn path<'p, T>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&T, ReflectPathError<'p>>where
T: Reflect,
path. Read moreSource§fn path_mut<'p, T>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut T, ReflectPathError<'p>>where
T: Reflect,
fn path_mut<'p, T>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut T, ReflectPathError<'p>>where
T: Reflect,
path. Read more