pub struct ProviderState { /* private fields */ }Expand description
Provider-owned state grouped off the App god-struct. Holds the
provider config, the edit form, the in-flight sync tracking
(cancel flags, completed names, error aggregate), the pending
delete alias, the on-disk sync history and the dirty-check baseline.
Pure state container.
Implementations§
Source§impl ProviderState
impl ProviderState
Sourcepub fn reset_batch_if_idle(&mut self)
pub fn reset_batch_if_idle(&mut self)
Reset batch counters when a completely new sync run begins.
Call before inserting into syncing on every spawn path. When both
syncing and sync_done are empty a fresh batch is starting, so
stale batch_total / batch_added / batch_updated / batch_stale
values from a previous (non-completed) run are cleared. Without this
guard a rare edge case could leak state from an interrupted batch
into a smaller follow-up batch and show “Syncing 1/5” while only
one provider is actually in flight.
Sourcepub fn finish_batch(&mut self)
pub fn finish_batch(&mut self)
Clear all batch tracking once a sync run has fully completed (no
providers left in syncing). Drops the completed-name list, the
error flag and every batch counter so the next run starts clean.
Sourcepub fn request_delete(&mut self, id: ProviderConfigId)
pub fn request_delete(&mut self, id: ProviderConfigId)
Open a delete confirmation for a provider config. pending_delete
carries the bare provider name for the renderer; pending_delete_id
carries the full id (including optional label) used by the confirm
handler to scope the removal to a single config when the provider
has multiple labeled configs.
Sourcepub fn cancel_delete(&mut self)
pub fn cancel_delete(&mut self)
Dismiss a pending provider delete confirmation. Idempotent.
Sourcepub fn toggle_expanded(&mut self, name: &str) -> bool
pub fn toggle_expanded(&mut self, name: &str) -> bool
Toggle the expanded state of a provider group in the tree-style
provider list. Returns true when the provider is now expanded
(was added) and false when it is now collapsed (was removed)
so the caller can log the transition without re-reading state.
Sourcepub fn cancel_label_migration(&mut self)
pub fn cancel_label_migration(&mut self)
Dismiss an in-progress lazy label-migration. Idempotent.
pub fn config(&self) -> &ProviderConfig
pub fn config_mut(&mut self) -> &mut ProviderConfig
pub fn form(&self) -> &ProviderFormFields
pub fn form_mut(&mut self) -> &mut ProviderFormFields
pub fn syncing(&self) -> &HashMap<String, Arc<AtomicBool>>
pub fn syncing_mut(&mut self) -> &mut HashMap<String, Arc<AtomicBool>>
pub fn sync_done(&self) -> &[String]
pub fn push_sync_done(&mut self, name: String)
pub fn clear_sync_done(&mut self)
pub fn sync_had_errors(&self) -> bool
pub fn set_sync_had_errors(&mut self, value: bool)
pub fn batch_added(&self) -> usize
pub fn batch_updated(&self) -> usize
pub fn batch_stale(&self) -> usize
Sourcepub fn add_batch_diff(&mut self, added: usize, updated: usize, stale: usize)
pub fn add_batch_diff(&mut self, added: usize, updated: usize, stale: usize)
Fold one provider’s diff counts into the current batch aggregate rendered by the footer summary.
pub fn batch_total(&self) -> usize
pub fn set_batch_total(&mut self, value: usize)
Sourcepub fn bump_batch_total(&mut self)
pub fn bump_batch_total(&mut self)
Raise batch_total to at least the number of providers known to be
part of the current batch (done plus still syncing). Never lowers it
so the n/total counter stays stable as providers complete.
pub fn pending_delete(&self) -> Option<&str>
pub fn take_pending_delete(&mut self) -> Option<String>
pub fn pending_delete_id(&self) -> Option<&ProviderConfigId>
pub fn take_pending_delete_id(&mut self) -> Option<ProviderConfigId>
pub fn sync_history(&self) -> &HashMap<String, SyncRecord>
pub fn sync_history_mut(&mut self) -> &mut HashMap<String, SyncRecord>
Sourcepub fn record_sync(&mut self, key: String, record: SyncRecord)
pub fn record_sync(&mut self, key: String, record: SyncRecord)
Record a provider’s sync outcome in the on-disk-backed history map, overwriting any previous record for the same key.
pub fn form_baseline(&self) -> Option<&ProviderFormBaseline>
pub fn set_form_baseline(&mut self, baseline: Option<ProviderFormBaseline>)
pub fn expanded_providers(&self) -> &HashSet<String>
pub fn expanded_providers_mut(&mut self) -> &mut HashSet<String>
pub fn pending_label_migration(&self) -> Option<&PendingLabelMigration>
pub fn pending_label_migration_mut( &mut self, ) -> Option<&mut PendingLabelMigration>
pub fn set_pending_label_migration( &mut self, migration: Option<PendingLabelMigration>, )
Source§impl ProviderState
impl ProviderState
Sourcepub fn provider_list_rows(&self) -> Vec<ProviderRow>
pub fn provider_list_rows(&self) -> Vec<ProviderRow>
One row in the provider list, in display order.
Each provider is a Header. When the provider has 2+ labeled configs
AND is in expanded_providers, its Leaf rows follow immediately.
When the provider has 0 or 1 config, no leaves are emitted.
Sourcepub fn sorted_names(&self) -> Vec<String>
pub fn sorted_names(&self) -> Vec<String>
Provider names sorted by last sync (most recent first), then configured, then unconfigured. Includes any unknown provider names found in the config file (e.g. typos or future providers).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ProviderState
impl RefUnwindSafe for ProviderState
impl Send for ProviderState
impl Sync for ProviderState
impl Unpin for ProviderState
impl UnsafeUnpin for ProviderState
impl UnwindSafe for ProviderState
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> 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