pub struct History {
pub version: u32,
pub projects: HashMap<PathBuf, ProjectHistory>,
}Expand description
Global history storage.
Fields§
§version: u32Version of the history format.
projects: HashMap<PathBuf, ProjectHistory>History per project path.
Implementations§
Source§impl History
impl History
Sourcepub fn load() -> Result<Self>
pub fn load() -> Result<Self>
Load history from the default location.
Handles missing files gracefully (returns empty history). Handles corrupt files by backing up and returning empty history.
Sourcepub fn get_project(&self, project_dir: &Path) -> Option<&ProjectHistory>
pub fn get_project(&self, project_dir: &Path) -> Option<&ProjectHistory>
Get history for a project.
Sourcepub fn get_project_mut(
&mut self,
project_dir: &Path,
) -> Option<&mut ProjectHistory>
pub fn get_project_mut( &mut self, project_dir: &Path, ) -> Option<&mut ProjectHistory>
Get mutable history for a project.
Sourcepub fn get_or_create_project(
&mut self,
project_dir: &Path,
) -> &mut ProjectHistory
pub fn get_or_create_project( &mut self, project_dir: &Path, ) -> &mut ProjectHistory
Get or create history for a project.
Sourcepub fn record_run(
&mut self,
project_dir: &Path,
script: &str,
args: Option<String>,
)
pub fn record_run( &mut self, project_dir: &Path, script: &str, args: Option<String>, )
Record a script execution.
Sourcepub fn get_last_script(
&self,
project_dir: &Path,
) -> Option<(String, Option<String>)>
pub fn get_last_script( &self, project_dir: &Path, ) -> Option<(String, Option<String>)>
Get the last executed script for a project with its arguments.
Sourcepub fn get_script_stats(
&self,
project_dir: &Path,
script: &str,
) -> Option<&ScriptHistory>
pub fn get_script_stats( &self, project_dir: &Path, script: &str, ) -> Option<&ScriptHistory>
Get statistics for a specific script in a project.
Sourcepub fn get_sorted_by_recent<'a>(
&self,
project_dir: &Path,
scripts: &'a [Script],
) -> Vec<&'a Script>
pub fn get_sorted_by_recent<'a>( &self, project_dir: &Path, scripts: &'a [Script], ) -> Vec<&'a Script>
Sort scripts by recent usage (most recently/frequently used first).
Scripts with history are sorted by score, scripts without history are placed at the end in their original order.
Sourcepub fn get_sorted_by_recent_at<'a>(
&self,
project_dir: &Path,
scripts: &'a [Script],
now: DateTime<Utc>,
) -> Vec<&'a Script>
pub fn get_sorted_by_recent_at<'a>( &self, project_dir: &Path, scripts: &'a [Script], now: DateTime<Utc>, ) -> Vec<&'a Script>
Sort scripts by recent usage at a specific time (for testing).
Sourcepub fn cleanup(&mut self, config: &HistoryConfig)
pub fn cleanup(&mut self, config: &HistoryConfig)
Enforce max_projects and max_scripts limits using LRU eviction.
Sourcepub fn cleanup_with_limits(&mut self, max_projects: usize, max_scripts: usize)
pub fn cleanup_with_limits(&mut self, max_projects: usize, max_scripts: usize)
Cleanup with specific limits.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for History
impl<'de> Deserialize<'de> for History
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for History
impl RefUnwindSafe for History
impl Send for History
impl Sync for History
impl Unpin for History
impl UnwindSafe for History
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> 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>
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