pub struct TunnelState { /* private fields */ }Expand description
Tunnel-owned state grouped off the App god-struct. Contains the rule
list, the edit form, the live child-process map, form baseline for the
dirty check, the pending delete index and the cached per-host summary
strings. Pure state container; behaviour lives on App or on dedicated
methods here.
Implementations§
Source§impl TunnelState
impl TunnelState
pub fn list(&self) -> &[TunnelRule]
pub fn list_mut(&mut self) -> &mut Vec<TunnelRule>
pub fn form(&self) -> &TunnelForm
pub fn form_mut(&mut self) -> &mut TunnelForm
pub fn reset_form(&mut self)
pub fn active(&self) -> &HashMap<String, ActiveTunnel>
pub fn active_get(&self, alias: &str) -> Option<&ActiveTunnel>
pub fn active_get_mut(&mut self, alias: &str) -> Option<&mut ActiveTunnel>
pub fn active_contains(&self, alias: &str) -> bool
pub fn active_insert(&mut self, alias: String, tunnel: ActiveTunnel)
pub fn active_remove(&mut self, alias: &str) -> Option<ActiveTunnel>
pub fn drain_active(&mut self) -> Drain<'_, String, ActiveTunnel>
pub fn clear_active(&mut self)
pub fn pending_delete(&self) -> Option<usize>
pub fn take_pending_delete(&mut self) -> Option<usize>
pub fn sort_mode(&self) -> TunnelSortMode
pub fn set_sort_mode(&mut self, mode: TunnelSortMode)
pub fn form_baseline(&self) -> Option<&TunnelFormBaseline>
pub fn set_form_baseline(&mut self, baseline: Option<TunnelFormBaseline>)
pub fn demo_live_snapshots(&self) -> &HashMap<String, TunnelLiveSnapshot>
pub fn demo_live_snapshots_mut( &mut self, ) -> &mut HashMap<String, TunnelLiveSnapshot>
pub fn parser_tx(&self) -> Sender<ParserMessage>
pub fn clients(&self) -> &HashMap<u16, Vec<ClientPeer>>
pub fn peer_viz(&self) -> &HashMap<(u16, String), [u64; 12]>
pub fn peer_viz_last_push(&self) -> Option<Instant>
pub fn peer_viz_prev_push(&self) -> Option<Instant>
pub fn summaries_cache(&self) -> &HashMap<String, String>
pub fn summaries_cache_mut(&mut self) -> &mut HashMap<String, String>
Sourcepub fn request_delete(&mut self, idx: usize)
pub fn request_delete(&mut self, idx: usize)
Open a delete confirmation for the tunnel at idx. The renderer
reads pending_delete to draw the confirm overlay.
Sourcepub fn cancel_delete(&mut self)
pub fn cancel_delete(&mut self)
Dismiss a pending delete confirmation. Idempotent.
Sourcepub fn ensure_lsof_poller(&mut self)
pub fn ensure_lsof_poller(&mut self)
Ensure the shared lsof poller is running. Idempotent: a second
call after the poller is already up is a noop. Caller is
responsible for updating bind_ports afterwards.
Sourcepub fn set_lsof_ports(&self, ports: Vec<(String, u16, u32)>)
pub fn set_lsof_ports(&self, ports: Vec<(String, u16, u32)>)
Replace the lsof poller’s port list. Callers compute the
(alias, bind_port, tunnel_pid) tuples from the SSH config
directives because ActiveTunnel does not store the rule set
directly. The poller picks up the new list on its next iteration.
Sourcepub fn poll(&mut self) -> Vec<(String, String, bool)>
pub fn poll(&mut self) -> Vec<(String, String, bool)>
Drain the parser channel into per-tunnel live state, drain the
lsof channel into the shared clients and conflicts maps,
rotate per-tunnel history buckets and finally poll every active
child for exit. Returns (alias, message, is_error) tuples so the
outer loop can route them through notify_*.
Sourcepub fn push_peer_viz(&mut self, now: Instant)
pub fn push_peer_viz(&mut self, now: Instant)
Push one bucket of per-peer braille history. Called exactly
once per lsof arrival so the visible window encodes
PEER_VIZ_BUCKETS consecutive poll snapshots — long enough to
see the trend, short enough to react quickly to changes. The
renderer fills in smooth motion between pushes via
peer_viz_last_push / peer_viz_prev_push. Garbage-collects
entries for peers that no longer appear in self.clients.
Sourcepub fn prune_orphans(&mut self, valid_aliases: &HashSet<&str>)
pub fn prune_orphans(&mut self, valid_aliases: &HashSet<&str>)
Drop demo-mode tunnel snapshots whose alias is no longer in
valid_aliases. Called from App::reload_hosts. Outside demo
the map stays empty so this is a no-op, but a demo workflow that
renames or deletes a host should not leak the old snapshot.
Sourcepub fn migrate_alias(&mut self, old: &str, new: &str)
pub fn migrate_alias(&mut self, old: &str, new: &str)
Move the active-tunnel handle from old to new on host
rename. Called from App::migrate_alias_keyed_caches before
reload_hosts, whose prune step would otherwise drop entries
still under the old alias. No-op when old == new or no
active tunnel exists under old.
Trait Implementations§
Source§impl Default for TunnelState
impl Default for TunnelState
Source§impl Drop for TunnelState
impl Drop for TunnelState
Auto Trait Implementations§
impl Freeze for TunnelState
impl !RefUnwindSafe for TunnelState
impl Send for TunnelState
impl !Sync for TunnelState
impl Unpin for TunnelState
impl UnsafeUnpin for TunnelState
impl !UnwindSafe for TunnelState
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