pub struct StateTracker { /* private fields */ }
Expand description
Tracks state changes for a component with dirty checking optimization
Implementations§
Source§impl StateTracker
impl StateTracker
Sourcepub fn new(component_id: ComponentId, config: StateTrackingConfig) -> Self
pub fn new(component_id: ComponentId, config: StateTrackingConfig) -> Self
Create a new state tracker for a component
Sourcepub fn new_default(component_id: ComponentId) -> Self
pub fn new_default(component_id: ComponentId) -> Self
Create a state tracker with default configuration
Sourcepub fn update_state(
&mut self,
new_fields: HashMap<String, StateValue>,
) -> Result<Option<StateChanges>, ComponentError>
pub fn update_state( &mut self, new_fields: HashMap<String, StateValue>, ) -> Result<Option<StateChanges>, ComponentError>
Update the current state and detect changes
Sourcepub fn is_field_dirty(&self, field_name: &str) -> bool
pub fn is_field_dirty(&self, field_name: &str) -> bool
Check if a specific field is dirty
Sourcepub fn mark_field_clean(&mut self, field_name: &str)
pub fn mark_field_clean(&mut self, field_name: &str)
Mark a field as clean
Sourcepub fn get_dirty_fields(&self) -> Vec<String>
pub fn get_dirty_fields(&self) -> Vec<String>
Get all dirty fields
Sourcepub fn has_dirty_fields(&self) -> bool
pub fn has_dirty_fields(&self) -> bool
Check if any fields are dirty
Sourcepub fn flush_batch(&mut self) -> StateChanges
pub fn flush_batch(&mut self) -> StateChanges
Force flush of current batch
Sourcepub fn component_id(&self) -> ComponentId
pub fn component_id(&self) -> ComponentId
Get the component ID being tracked
Sourcepub fn current_snapshot(&self) -> Option<&StateSnapshot>
pub fn current_snapshot(&self) -> Option<&StateSnapshot>
Get current state snapshot
Sourcepub fn previous_snapshot(&self) -> Option<&StateSnapshot>
pub fn previous_snapshot(&self) -> Option<&StateSnapshot>
Get previous state snapshot
Auto Trait Implementations§
impl Freeze for StateTracker
impl RefUnwindSafe for StateTracker
impl Send for StateTracker
impl Sync for StateTracker
impl Unpin for StateTracker
impl UnwindSafe for StateTracker
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
Mutably borrows from an owned value. Read more