Skip to main content

ConnectionHistory

Struct ConnectionHistory 

Source
pub struct ConnectionHistory { /* private fields */ }
Expand description

Connection history tracking.

Implementations§

Source§

impl ConnectionHistory

Source

pub fn load() -> Self

Load connection history from disk.

Source

pub fn from_entries(entries: HashMap<String, HistoryEntry>) -> Self

Create a ConnectionHistory from pre-built entries (for demo use).

Source

pub fn entries(&self) -> &HashMap<String, HistoryEntry>

Source

pub fn entry(&self, alias: &str) -> Option<&HistoryEntry>

Source

pub fn upsert_entry(&mut self, entry: HistoryEntry)

Source

pub fn record(&mut self, alias: &str)

Record a connection to a host.

Source

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.

Source

pub fn last_connected(&self, alias: &str) -> u64

Last connected timestamp for a host (0 if never connected).

Source

pub fn frecency_score(&self, alias: &str) -> f64

Frecency score: count weighted by recency.

Source

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

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for ConnectionHistory

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ConnectionHistory

Source§

fn default() -> ConnectionHistory

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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