pub struct TunnelState {Show 19 fields
pub list: Vec<TunnelRule>,
pub form: TunnelForm,
pub active: HashMap<String, ActiveTunnel>,
pub form_baseline: Option<TunnelFormBaseline>,
pub pending_delete: Option<usize>,
pub summaries_cache: HashMap<String, String>,
pub sort_mode: TunnelSortMode,
pub parser_tx: Sender<ParserMessage>,
pub parser_rx: Receiver<ParserMessage>,
pub lsof_tx: Sender<LsofMessage>,
pub lsof_rx: Receiver<LsofMessage>,
pub clients: HashMap<u16, Vec<ClientPeer>>,
pub conflicts: HashMap<u16, PortConflict>,
pub last_lsof_at: Option<Instant>,
pub peer_viz: HashMap<(u16, String), [u64; 12]>,
pub peer_viz_last_push: Option<Instant>,
pub peer_viz_prev_push: Option<Instant>,
pub lsof: Option<LsofPollerHandle>,
pub demo_live_snapshots: HashMap<String, TunnelLiveSnapshot>,
}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.
Fields§
§list: Vec<TunnelRule>§form: TunnelForm§active: HashMap<String, ActiveTunnel>§form_baseline: Option<TunnelFormBaseline>§pending_delete: Option<usize>§summaries_cache: HashMap<String, String>§sort_mode: TunnelSortModeSort mode for the tunnels overview screen. Cycled by s.
parser_tx: Sender<ParserMessage>§parser_rx: Receiver<ParserMessage>§lsof_tx: Sender<LsofMessage>§lsof_rx: Receiver<LsofMessage>§clients: HashMap<u16, Vec<ClientPeer>>§conflicts: HashMap<u16, PortConflict>§last_lsof_at: Option<Instant>§peer_viz: HashMap<(u16, String), [u64; 12]>Per-peer rolling braille history, pushed once per lsof poll
arrival from poll(). Keyed by (bind_port, peer.src) so it
survives wholesale clients replacements as long as the peer is
still in the new snapshot. Each cell carries one
current_rx_bps + current_tx_bps snapshot from a single lsof
poll, so the visible window covers PEER_VIZ_BUCKETS polls
(~24-48s on Linux/macOS).
peer_viz_last_push: Option<Instant>Wall-clock of the most recent push_peer_viz rotation, and the
one before it. The renderer divides (now - last) / (last - prev)
to derive a smooth phase in [0, 1] that drifts the wave
leftward by exactly one bucket between pushes — adaptive to the
actual poll interval (which varies on macOS due to nettop
overhead).
peer_viz_prev_push: Option<Instant>§lsof: Option<LsofPollerHandle>§demo_live_snapshots: HashMap<String, TunnelLiveSnapshot>Demo / test seed. When App.demo_mode == true the detail panel
reads from this map instead of the live counters, so visual
regression tests are byte-deterministic.
Implementations§
Source§impl TunnelState
impl TunnelState
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.
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