Skip to main content

KeyPushState

Struct KeyPushState 

Source
pub struct KeyPushState {
Show 13 fields pub selected: HashSet<String>, pub committed: Vec<String>, pub list_state: ListState, pub results: Vec<KeyPushResult>, pub pin_outcomes: HashMap<String, PinOutcome>, pub expected_count: usize, pub cancel: Option<Arc<AtomicBool>>, pub worker: Option<JoinHandle<()>>, pub run_id: u64, pub inflight: InflightChild, pub key_path: String, pub trust_new_host_key: bool, pub pending_prompts: VecDeque<KeyPushPrompt>,
}
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.

§pin_outcomes: HashMap<String, PinOutcome>

What each landed host’s run said about security key PINs, settled as its result arrives so the PIN markers are still fresh.

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

§inflight: InflightChild

The ssh child the worker is running right now. Cancel and shutdown kill it through here instead of waiting for the worker to notice the flag between hosts.

§key_path: String

Path of the key the current run pushes, as SshKeyInfo::display_path spells it. A retry after a dialog looks the key up by this path: the list is rebuilt after a successful push, so a position would not survive.

§trust_new_host_key: bool

True when the current run follows an accepted trust dialog, so its ssh may record a host key it has not seen before. Reset by every start_run, so it never carries into an ordinary push.

§pending_prompts: VecDeque<KeyPushPrompt>

Hosts of the finished run that still need an answer, in picker order. Drained one dialog at a time, never while a run is in flight.

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. The running child is killed first so the join returns within the SIGTERM grace window.

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, key_path: String, trust_new_host_key: bool, ) -> (u64, Arc<AtomicBool>)

Begin a new push run. Clears the result accumulator, sets the expected host count and the path of the key being pushed, bumps the monotonic run_id (so any stale KeyPushResult events from an aborted previous run can be dropped), constructs a fresh cancel flag and an empty inflight slot and stores them 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 running child is killed and the cancel flag is raised for the worker. Accumulators and pending prompts are cleared and run_id is bumped so in-flight KeyPushResult events from the aborted 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 reaps the child.

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() -> Self

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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