pub struct ProjectIndex {
pub projects: HashMap<String, Project>,
pub last_sync: DateTime<Utc>,
pub version: u32,
}Expand description
Project index with caching and sync capabilities
Fields§
§projects: HashMap<String, Project>All discovered projects, keyed by absolute path
last_sync: DateTime<Utc>Last sync timestamp
version: u32Schema version for future migrations
Implementations§
Source§impl ProjectIndex
impl ProjectIndex
Sourcepub fn load() -> Result<Self>
pub fn load() -> Result<Self>
Load index from cache file (~/.cache/px/projects.json)
If the cache file doesn’t exist or can’t be read, returns a new empty index.
This makes the first run seamless - users just run px sync to populate.
Sourcepub fn save(&self) -> Result<()>
pub fn save(&self) -> Result<()>
Save index to cache file
Creates the cache directory if it doesn’t exist.
Sourcepub fn sync(&mut self, scan_dirs: &[PathBuf]) -> Result<usize>
pub fn sync(&mut self, scan_dirs: &[PathBuf]) -> Result<usize>
Sync/rebuild the project index by scanning configured directories
This is the core indexing operation that:
- Scans all configured directories for git repositories
- Extracts metadata for each project
- Preserves frecency data for existing projects
- Saves the updated index to disk
Returns the number of projects found.
Sourcepub fn record_access(&mut self, project_path: &str) -> Result<()>
pub fn record_access(&mut self, project_path: &str) -> Result<()>
Record project access for frecency tracking
Updates access_count, last_accessed, and recalculates frecency_score. Changes are persisted to disk immediately.
Sourcepub fn sorted_projects(&self) -> Vec<&Project>
pub fn sorted_projects(&self) -> Vec<&Project>
Get projects as a sorted vector (by frecency)
Trait Implementations§
Source§impl Debug for ProjectIndex
impl Debug for ProjectIndex
Source§impl Default for ProjectIndex
impl Default for ProjectIndex
Source§impl<'de> Deserialize<'de> for ProjectIndex
impl<'de> Deserialize<'de> for ProjectIndex
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 ProjectIndex
impl RefUnwindSafe for ProjectIndex
impl Send for ProjectIndex
impl Sync for ProjectIndex
impl Unpin for ProjectIndex
impl UnwindSafe for ProjectIndex
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