pub struct DependencyIndex { /* private fields */ }Expand description
Global cross-project dependency index backed by SQLite.
§Thread safety
The underlying rusqlite::Connection is guarded by a Mutex so
DependencyIndex is Send + Sync.
Implementations§
Source§impl DependencyIndex
impl DependencyIndex
Sourcepub fn open(path: &Path) -> Result<Self, DependencyIndexError>
pub fn open(path: &Path) -> Result<Self, DependencyIndexError>
Open or create the dependency index at the given path.
Creates parent directories if they do not exist, opens the database in WAL mode, and initialises the schema.
§Errors
Returns DependencyIndexError::Io if the parent directory cannot be
created, or DependencyIndexError::Sqlite if the database cannot be
opened or the schema cannot be initialised.
Sourcepub fn index_project(
&self,
project_root: &Path,
) -> Result<usize, DependencyIndexError>
pub fn index_project( &self, project_root: &Path, ) -> Result<usize, DependencyIndexError>
Parse a project manifest file and index its dependencies.
Detects the manifest type from files present in project_root and
inserts all discovered dependencies. Returns the count of rows
inserted.
§Errors
Returns DependencyIndexError::Io if the manifest cannot be read, or
DependencyIndexError::Parse if the manifest is malformed, or
DependencyIndexError::Sqlite if a database write fails.
Sourcepub fn projects_using(
&self,
dependency: &str,
) -> Result<Vec<DependencyEntry>, DependencyIndexError>
pub fn projects_using( &self, dependency: &str, ) -> Result<Vec<DependencyEntry>, DependencyIndexError>
Query: which projects depend on the given library?
§Errors
Returns DependencyIndexError::Sqlite if the query fails.
Sourcepub fn dependencies_of(
&self,
project_path: &str,
) -> Result<Vec<DependencyEntry>, DependencyIndexError>
pub fn dependencies_of( &self, project_path: &str, ) -> Result<Vec<DependencyEntry>, DependencyIndexError>
Query: what does the given project depend on?
§Errors
Returns DependencyIndexError::Sqlite if the query fails.