Skip to main content

PropertyStore

Struct PropertyStore 

Source
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

Source

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).

Source

pub fn get(&self, key: &PropertyKey) -> Option<&PropertyValue>

Returns a shared reference to the cell’s value, or None when the key is absent.

Source

pub fn cell(&self, key: &PropertyKey) -> Option<&PropertyCell>

Returns a shared reference to the full cell, or None when the key is absent.

Source

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.

Source

pub fn contains(&self, key: &PropertyKey) -> bool

Returns true when key has a cell.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn dirty_peek(&self) -> &[PropertyKey]

Returns a snapshot of the current dirty queue without draining it.

Source

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.

Source

pub fn len(&self) -> usize

Number of stored cells. Useful for tests and devtools.

Source

pub fn is_empty(&self) -> bool

Returns true when no cells are stored.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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
where Self: Send + Sync + 'static,

Source§

const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::SparseSet

A constant indicating the storage type used for this component.
Source§

type Mutability = Mutable

A marker type to assist Bevy with determining if this component is mutable, or immutable. Mutable components will have Component<Mutability = Mutable>, while immutable components will instead have Component<Mutability = Immutable>. Read more
Source§

fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )

Registers required components. Read more
Source§

fn clone_behavior() -> ComponentCloneBehavior

Called when registering this component, allowing to override clone function (or disable cloning altogether) for this component. Read more
Source§

fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>

Returns [ComponentRelationshipAccessor] required for working with relationships in dynamic contexts. Read more
§

fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_add [ComponentHook] for this Component if one is defined.
§

fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_insert [ComponentHook] for this Component if one is defined.
§

fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_discard [ComponentHook] for this Component if one is defined.
§

fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_remove [ComponentHook] for this Component if one is defined.
§

fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_despawn [ComponentHook] for this Component if one is defined.
§

fn map_entities<E>(_this: &mut Self, _mapper: &mut E)
where E: EntityMapper,

Maps the entities on this component using the given 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 more
Source§

impl Debug for PropertyStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PropertyStore

Source§

fn default() -> PropertyStore

Returns the “default value” for a type. Read more
Source§

impl Resource for PropertyStore
where Self: Send + Sync + 'static,

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<C> Bundle for C
where C: Component,

§

fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>

§

fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>

Return a iterator over this Bundle’s component ids. This will be None if the component has not been registered.
§

impl<C> BundleFromComponents for C
where C: Component,

§

unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> C
where F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a>,

§

impl<C> DynamicBundle for C
where C: Component,

§

type Effect = ()

An operation on the entity that happens after inserting this bundle.
§

unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect

Moves the components out of the bundle. Read more
§

unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )

Applies the after-effects of spawning this bundle. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromWorld for T
where T: Default,

§

fn from_world(_world: &mut World) -> T

Creates Self using default().

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoResult<T> for T

§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> ConditionalSend for T
where T: Send,