pub mod paths;
#[cfg(feature = "backend-sqlite")]
pub mod sqlite_backend;
#[cfg(all(feature = "sqlite", not(feature = "backend-sqlite")))]
pub mod sqlite_backend;
pub mod backend;
pub mod mirage_db;
pub mod operations;
pub mod queries;
pub mod schema;
use anyhow::Result;
#[cfg(feature = "backend-sqlite")]
pub use sqlite_backend::SqliteStorage;
#[allow(unused_imports)]
pub use paths::{
get_cached_paths, invalidate_function_paths, store_paths, update_function_paths_if_changed,
PathCache,
};
pub use backend::{Backend, BackendFormat};
pub use mirage_db::{DatabaseStatus, MirageDb};
pub use schema::{create_minimal_database, create_schema, migrate_schema};
pub use operations::{
load_cfg_from_db, load_cfg_from_db_with_conn, resolve_function_name,
resolve_function_name_with_conn, resolve_function_name_with_file,
};
#[allow(deprecated)]
pub use queries::{
compute_path_impact_from_db, function_exists, get_changed_functions, get_function_file,
get_function_file_db, get_function_hash, get_function_hash_db, get_function_name,
get_function_name_db, get_path_elements, hash_changed, store_cfg,
};
type CfgBlockRow = (
i64,
String,
Option<String>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<String>,
);
pub trait StorageTrait {
fn get_cfg_blocks(&self, function_id: i64) -> Result<Vec<CfgBlockData>>;
fn get_entity(&self, entity_id: i64) -> Option<sqlitegraph::GraphEntity>;
fn get_cached_paths(&self, _function_id: i64) -> Result<Option<Vec<crate::cfg::Path>>> {
Ok(None)
}
fn get_callees(&self, _function_id: i64) -> Result<Vec<i64>> {
Ok(Vec::new())
}
fn get_documents_for_function(&self, _function_id: i64) -> Result<Vec<DocumentInfo>> {
Ok(Vec::new())
}
fn get_facts_for_function(&self, _function_id: i64) -> Result<Vec<FactInfo>> {
Ok(Vec::new())
}
fn list_source_documents(&self) -> Result<Vec<DocumentInfo>> {
Ok(Vec::new())
}
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct CfgBlockData {
pub id: i64,
pub kind: String,
pub terminator: String,
pub byte_start: u64,
pub byte_end: u64,
pub start_line: u64,
pub start_col: u64,
pub end_line: u64,
pub end_col: u64,
pub coord_x: i64,
pub coord_y: i64,
pub coord_z: i64,
pub cfg_condition: Option<String>,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct DocumentInfo {
pub id: i64,
pub path_or_uri: String,
pub source_kind: String,
pub title: Option<String>,
pub tags: Option<String>,
pub wikilinks: Option<String>,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct FactInfo {
pub candidate_id: String,
pub subject_type: String,
pub subject_key: String,
pub predicate: String,
pub object_type: Option<String>,
pub object_key: Option<String>,
pub status: String,
pub source_document_id: i64,
}
pub const MIRAGE_SCHEMA_VERSION: i32 = 1;
pub const MIN_MAGELLAN_SCHEMA_VERSION: i32 = 7;
pub const TEST_MAGELLAN_SCHEMA_VERSION: i32 = MIN_MAGELLAN_SCHEMA_VERSION;
pub const REQUIRED_MAGELLAN_SCHEMA_VERSION: i32 = TEST_MAGELLAN_SCHEMA_VERSION;
pub const REQUIRED_SQLITEGRAPH_SCHEMA_VERSION: i32 = 3;