pub struct KeyPushState {
pub selected: HashSet<String>,
pub committed: Vec<String>,
pub list_state: ListState,
pub results: Vec<KeyPushResult>,
pub expected_count: usize,
pub cancel: Option<Arc<AtomicBool>>,
pub worker: Option<JoinHandle<()>>,
pub run_id: u64,
}Expand description
Push state owned by App. Empty between push runs.
Fields§
§selected: HashSet<String>Aliases the user has selected in the picker. Modified by Space
during Screen::KeyPushPicker and frozen into committed on Enter.
committed: Vec<String>Snapshot of selected (in picker order) taken when the user
presses Enter to open Screen::ConfirmKeyPush. Read by the
confirm renderer and by start_key_push. Cleared on cancel or
after the worker spawns. Keeps Screen::ConfirmKeyPush payload
small.
list_state: ListStateCursor in the picker’s host list. Indexes into the picker’s visible host slice.
results: Vec<KeyPushResult>Results accumulated as AppEvent::KeyPushResult lands. Drained
when the run completes and the summary toast / sticky error is
rendered.
expected_count: usizeTotal hosts the current run is targeting. Used to know when the run is “done” so the summary can fire exactly once.
cancel: Option<Arc<AtomicBool>>Cancel flag observed by every worker thread. Set on push-cancel, new push run, or App drop.
worker: Option<JoinHandle<()>>JoinHandle for the worker pool. Joined on App drop.
run_id: u64Monotonic run identifier. Bumped at the start of every push so
stale KeyPushResult events from a previously-cancelled run can
be dropped instead of contaminating the next run’s accumulator.
Implementations§
Source§impl KeyPushState
impl KeyPushState
Sourcepub fn shutdown(&mut self)
pub fn shutdown(&mut self)
Drop the worker handle gracefully. Called from App::drop so a
panicking unwind cannot leave the push thread running with a
dangling sender.
Sourcepub fn reset_picker(&mut self)
pub fn reset_picker(&mut self)
Reset picker-only state without touching in-flight worker. Called before opening the picker for a new key so the previous run’s selection set does not bleed in.
Sourcepub fn start_run(&mut self, expected: usize) -> (u64, Arc<AtomicBool>)
pub fn start_run(&mut self, expected: usize) -> (u64, Arc<AtomicBool>)
Begin a new push run. Clears the result accumulator, sets the expected host count, bumps the monotonic run_id (so any stale KeyPushResult events from a cancelled previous run can be dropped), constructs a fresh cancel flag and stores it on state. Returns the new run_id together with the cancel handle so the spawned worker can share it.
Sourcepub fn finish_run(&mut self)
pub fn finish_run(&mut self)
Completion path. The worker loop has finished naturally; clear the accumulators and join the worker handle. Safe to call when the worker has already exited.
Sourcepub fn cancel_run(&mut self)
pub fn cancel_run(&mut self)
User-cancel path. The cancel flag is dropped, accumulators are cleared, and run_id is bumped so in-flight KeyPushResult events from the cancelled worker arrive with a stale run_id and are dropped. The worker handle is intentionally NOT joined here so the UI does not block while the thread observes the cancel flag.
Sourcepub fn clear_inflight_state(&mut self)
pub fn clear_inflight_state(&mut self)
Failure recovery after a failed worker spawn. Drops the cancel
handle, zeroes the expected count, and clears the worker slot.
Distinct from finish_run: the worker handle is None here (spawn
failed), and the result accumulator is left intact for any caller
that may want to surface it in the error path.
Trait Implementations§
Source§impl Default for KeyPushState
impl Default for KeyPushState
Source§fn default() -> KeyPushState
fn default() -> KeyPushState
Auto Trait Implementations§
impl Freeze for KeyPushState
impl !RefUnwindSafe for KeyPushState
impl Send for KeyPushState
impl Sync for KeyPushState
impl Unpin for KeyPushState
impl UnsafeUnpin for KeyPushState
impl !UnwindSafe for KeyPushState
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