Skip to main content

ProviderState

Struct ProviderState 

Source
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: bool

Whether any provider in the current batch had errors.

§batch_added: usize

Aggregate 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: usize

Total 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

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

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