Skip to main content

ProviderState

Struct ProviderState 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn cancel_delete(&mut self)

Dismiss a pending provider delete confirmation. Idempotent.

Source

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.

Source

pub fn cancel_label_migration(&mut self)

Dismiss an in-progress lazy label-migration. Idempotent.

Source

pub fn config(&self) -> &ProviderConfig

Source

pub fn config_mut(&mut self) -> &mut ProviderConfig

Source

pub fn form(&self) -> &ProviderFormFields

Source

pub fn form_mut(&mut self) -> &mut ProviderFormFields

Source

pub fn syncing(&self) -> &HashMap<String, Arc<AtomicBool>>

Source

pub fn syncing_mut(&mut self) -> &mut HashMap<String, Arc<AtomicBool>>

Source

pub fn sync_done(&self) -> &[String]

Source

pub fn push_sync_done(&mut self, name: String)

Source

pub fn clear_sync_done(&mut self)

Source

pub fn sync_had_errors(&self) -> bool

Source

pub fn set_sync_had_errors(&mut self, value: bool)

Source

pub fn batch_added(&self) -> usize

Source

pub fn batch_updated(&self) -> usize

Source

pub fn batch_stale(&self) -> usize

Source

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.

Source

pub fn batch_total(&self) -> usize

Source

pub fn set_batch_total(&mut self, value: usize)

Source

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.

Source

pub fn pending_delete(&self) -> Option<&str>

Source

pub fn take_pending_delete(&mut self) -> Option<String>

Source

pub fn pending_delete_id(&self) -> Option<&ProviderConfigId>

Source

pub fn take_pending_delete_id(&mut self) -> Option<ProviderConfigId>

Source

pub fn sync_history(&self) -> &HashMap<String, SyncRecord>

Source

pub fn sync_history_mut(&mut self) -> &mut HashMap<String, SyncRecord>

Source

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.

Source

pub fn form_baseline(&self) -> Option<&ProviderFormBaseline>

Source

pub fn set_form_baseline(&mut self, baseline: Option<ProviderFormBaseline>)

Source

pub fn expanded_providers(&self) -> &HashSet<String>

Source

pub fn expanded_providers_mut(&mut self) -> &mut HashSet<String>

Source

pub fn pending_label_migration(&self) -> Option<&PendingLabelMigration>

Source

pub fn pending_label_migration_mut( &mut self, ) -> Option<&mut PendingLabelMigration>

Source

pub fn set_pending_label_migration( &mut self, migration: Option<PendingLabelMigration>, )

Source§

impl ProviderState

Source

pub fn load() -> Self

Construct with persisted state loaded from disk.

Source

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.

Source

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§

Source§

impl Default for ProviderState

Source§

fn default() -> Self

Truly empty default. No disk I/O. Call sites that need persisted state (App::new) construct with struct-update syntax: ProviderState { config: ProviderConfig::load(), sync_history: SyncRecord::load_all(), ..Default::default() }.

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V