pub struct PropertyStore { /* private fields */ }Expand description
Reactive typed property store. Replaces the legacy Signals: HashMap<String, String> with a notify-on-write store.
Read crate::signals::Signals for backward-compatible callers; new code should use this store directly.
Implementations§
Source§impl PropertyStore
impl PropertyStore
Sourcepub fn set(&mut self, key: PropertyKey, value: PropertyValue) -> bool
pub fn set(&mut self, key: PropertyKey, value: PropertyValue) -> bool
Writes value into the cell for key. Bumps the cell’s generation and, unless Self::freeze_notify is active,
appends key to the dirty queue.
Returns true when the stored value actually changed (semantically equal writes skip the dirty push - matches
GObject’s notify behaviour).
Sourcepub fn get(&self, key: &PropertyKey) -> Option<&PropertyValue>
pub fn get(&self, key: &PropertyKey) -> Option<&PropertyValue>
Returns a shared reference to the cell’s value, or None when the key is absent.
Sourcepub fn cell(&self, key: &PropertyKey) -> Option<&PropertyCell>
pub fn cell(&self, key: &PropertyKey) -> Option<&PropertyCell>
Returns a shared reference to the full cell, or None when the key is absent.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&PropertyKey, &PropertyValue)>
pub fn iter(&self) -> impl Iterator<Item = (&PropertyKey, &PropertyValue)>
Iterate over every (key, value) pair in storage, in arbitrary
order. Used by mirror_property_store_to_typed_cache to
snapshot the typed scalar cells into a process-wide cache that
FFI accessors read from any thread.
Sourcepub fn contains(&self, key: &PropertyKey) -> bool
pub fn contains(&self, key: &PropertyKey) -> bool
Returns true when key has a cell.
Sourcepub fn listener_count(&self, key: &PropertyKey) -> usize
pub fn listener_count(&self, key: &PropertyKey) -> usize
Returns the number of listeners registered for key (currently always 0 - wave 1 wires the listener API).
Sourcepub fn add_listener(&mut self, key: PropertyKey) -> ListenerId
pub fn add_listener(&mut self, key: PropertyKey) -> ListenerId
Allocates and registers a fresh listener id against key. The cell is auto-created with a [PropertyValue::Bool(false)] sentinel when absent;
the next set overwrites it.
Sourcepub fn bind(&mut self, dst: PropertyKey, _src: PropertyKey) -> BindingId
pub fn bind(&mut self, dst: PropertyKey, _src: PropertyKey) -> BindingId
Registers a one-way binding from src to dst. Returns the BindingId stored on the destination cell.
Wave 1 wires the actual propagation system; this method only records the wiring intent today.
Sourcepub fn freeze_notify(&mut self)
pub fn freeze_notify(&mut self)
Pushes the freeze counter so subsequent set calls write the cell without appending to dirty.
Pair with Self::thaw_notify; nested freeze/thaw is supported.
Sourcepub fn thaw_notify(&mut self)
pub fn thaw_notify(&mut self)
Pops the freeze counter. When the depth reaches zero, no implicit dirty flush happens - callers that need to
fire deferred notifies should manually re-set the affected keys after thaw.
Sourcepub fn drain_dirty(&mut self) -> SmallVec<[PropertyKey; 16]>
pub fn drain_dirty(&mut self) -> SmallVec<[PropertyKey; 16]>
Drains the per-tick dirty queue, returning the dirtied keys. Downstream systems call this once per tick.
Sourcepub fn dirty_peek(&self) -> &[PropertyKey]
pub fn dirty_peek(&self) -> &[PropertyKey]
Returns a snapshot of the current dirty queue without draining it.
Sourcepub fn clear_dirty(&mut self)
pub fn clear_dirty(&mut self)
Clear the per-tick dirty queue without consuming it. Sibling to Self::drain_dirty
for callers that only want the reset side-effect - used by the end-of-tick
clear_property_store_dirty system to drop accumulated entries after every consumer
(derivations, theme propagation, …) has already peeked.
Sourcepub fn get_global_str(&self, name: &str) -> Option<Arc<str>>
pub fn get_global_str(&self, name: &str) -> Option<Arc<str>>
Reads a globally-keyed string cell, stringifying scalar variants on demand.
Returns None when the cell is absent.
Coercion matches the [From<PropertyValue> for Arc<str>] impl above:
Bool -> "true" / "false"; I64 / F64 -> decimal repr; non-scalar
variants (Color, Vec2, Custom) yield Some("") - callers that
need the typed value should pattern-match the raw cell.
Sourcepub fn set_global_str(&mut self, name: &str, value: impl Into<Arc<str>>) -> bool
pub fn set_global_str(&mut self, name: &str, value: impl Into<Arc<str>>) -> bool
Writes a string into a globally-keyed cell. Convenience for the common
set(PropertyKey::Global(name), PropertyValue::Str(value)) pattern.
Sourcepub fn get_global_bool(&self, name: &str) -> Option<bool>
pub fn get_global_bool(&self, name: &str) -> Option<bool>
Reads a globally-keyed boolean. Recognises Bool directly, plus the
canonical "true" / "false" / "1" / "0" string aliases that
crate::signals::Signals::set_bool used to write. Other variants
(numeric, colour, …) yield None so callers can fall back to a default
rather than treating an unrelated value as false.
Sourcepub fn set_global_bool(&mut self, name: &str, value: bool) -> bool
pub fn set_global_bool(&mut self, name: &str, value: bool) -> bool
Writes a boolean as the canonical "true" / "false" string variant.
Mirrors crate::signals::Signals::set_bool semantics so downstream
readers that still consult string variants (<if eq="true"> body
comparator) keep working post-migration.
Sourcepub fn dirty_global_names(&self) -> impl Iterator<Item = &str>
pub fn dirty_global_names(&self) -> impl Iterator<Item = &str>
Iterates the per-tick dirty queue and yields just the global property
names. Replaces direct iteration over the legacy Signals::dirty set.
Trait Implementations§
Source§impl Component for PropertyStore
impl Component for PropertyStore
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::SparseSet
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::SparseSet
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 more§fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
§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 Debug for PropertyStore
impl Debug for PropertyStore
Source§impl Default for PropertyStore
impl Default for PropertyStore
Source§fn default() -> PropertyStore
fn default() -> PropertyStore
impl Resource for PropertyStore
Auto Trait Implementations§
impl Freeze for PropertyStore
impl !RefUnwindSafe for PropertyStore
impl Send for PropertyStore
impl Sync for PropertyStore
impl Unpin for PropertyStore
impl UnsafeUnpin for PropertyStore
impl !UnwindSafe for PropertyStore
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<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>
§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
§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
§unsafe fn apply_effect(
_ptr: MovingPtr<'_, MaybeUninit<C>>,
_entity: &mut EntityWorldMut<'_>,
)
unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().