pub struct ConnectionHistory {
pub entries: HashMap<String, HistoryEntry>,
/* private fields */
}Expand description
Connection history tracking.
Fields§
§entries: HashMap<String, HistoryEntry>Implementations§
Source§impl ConnectionHistory
impl ConnectionHistory
Sourcepub fn from_entries(entries: HashMap<String, HistoryEntry>) -> Self
pub fn from_entries(entries: HashMap<String, HistoryEntry>) -> Self
Create a ConnectionHistory from pre-built entries (for demo use).
Sourcepub fn rename(&mut self, old_alias: &str, new_alias: &str) -> bool
pub fn rename(&mut self, old_alias: &str, new_alias: &str) -> bool
Move a host’s entry from old_alias to new_alias. Called from the
host-form rename path so connection counts and timestamps survive a
rename. When both keys carry entries (defensive, should not occur in
practice because SSH config writes reject collisions) the two are
merged: counts sum, the most recent last_connected wins, and the
timestamp lists are concatenated then pruned by the same retention
and cap rules used on load.
Returns true when the file changed.
Sourcepub fn last_connected(&self, alias: &str) -> u64
pub fn last_connected(&self, alias: &str) -> u64
Last connected timestamp for a host (0 if never connected).
Sourcepub fn frecency_score(&self, alias: &str) -> f64
pub fn frecency_score(&self, alias: &str) -> f64
Frecency score: count weighted by recency.
Sourcepub fn format_time_ago(timestamp: u64) -> String
pub fn format_time_ago(timestamp: u64) -> String
Format a timestamp as a human-readable “time ago” string.
Trait Implementations§
Source§impl Clone for ConnectionHistory
impl Clone for ConnectionHistory
Source§fn clone(&self) -> ConnectionHistory
fn clone(&self) -> ConnectionHistory
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConnectionHistory
impl Debug for ConnectionHistory
Source§impl Default for ConnectionHistory
impl Default for ConnectionHistory
Source§fn default() -> ConnectionHistory
fn default() -> ConnectionHistory
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ConnectionHistory
impl RefUnwindSafe for ConnectionHistory
impl Send for ConnectionHistory
impl Sync for ConnectionHistory
impl Unpin for ConnectionHistory
impl UnsafeUnpin for ConnectionHistory
impl UnwindSafe for ConnectionHistory
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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