Skip to main content

KeyPushState

Struct KeyPushState 

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

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

Total 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: u64

Monotonic 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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn default() -> KeyPushState

Returns the “default value” for a type. Read more

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