pub struct ProviderState {Show 15 fields
pub config: ProviderConfig,
pub form: ProviderFormFields,
pub syncing: HashMap<String, Arc<AtomicBool>>,
pub sync_done: Vec<String>,
pub sync_had_errors: bool,
pub batch_added: usize,
pub batch_updated: usize,
pub batch_stale: usize,
pub batch_total: usize,
pub pending_delete: Option<String>,
pub pending_delete_id: Option<ProviderConfigId>,
pub sync_history: HashMap<String, SyncRecord>,
pub form_baseline: Option<ProviderFormBaseline>,
pub expanded_providers: HashSet<String>,
pub pending_label_migration: Option<PendingLabelMigration>,
}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.
Fields§
§config: ProviderConfig§form: ProviderFormFields§syncing: HashMap<String, Arc<AtomicBool>>§sync_done: Vec<String>Names of providers that completed during this sync batch.
sync_had_errors: boolWhether any provider in the current batch had errors.
batch_added: usizeAggregate diff counts across the current sync batch. Reset when the
batch finishes (no providers left in syncing). Used by the footer
background status to render (+3 ~1 -2) next to the provider list.
batch_updated: usize§batch_stale: usize§batch_total: usizeTotal provider count for the current batch (done + still syncing).
Captured when sync starts so the n/total counter does not jump
when providers complete and leave syncing.
pending_delete: Option<String>§pending_delete_id: Option<ProviderConfigId>When deleting a single labeled config, this carries the full id.
pending_delete is used for whole-provider delete (header confirm).
sync_history: HashMap<String, SyncRecord>§form_baseline: Option<ProviderFormBaseline>§expanded_providers: HashSet<String>Provider names that are expanded in the tree-style provider list. Only matters when a provider has 2+ labeled configs.
pending_label_migration: Option<PendingLabelMigration>In-progress lazy migration: when adding a 2nd config of a provider that currently has a single bare config, we first prompt for a label for the existing config. The chosen label lives here until the new config form is saved (then both writes happen atomically). When the user cancels the new config form, this is dropped and nothing is written.
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 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.
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