pub struct Database { /* private fields */ }Implementations§
Source§impl Database
impl Database
Sourcepub fn open<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>
Open a Heroforge repository database (read-only)
Sourcepub fn get_blob_raw(&self, hash: &str) -> Result<(i64, Vec<u8>)>
pub fn get_blob_raw(&self, hash: &str) -> Result<(i64, Vec<u8>)>
Get raw blob content by hash (still compressed)
Sourcepub fn get_blob_for_sync(
&self,
hash: &str,
) -> Result<(Vec<u8>, i64, Option<String>)>
pub fn get_blob_for_sync( &self, hash: &str, ) -> Result<(Vec<u8>, i64, Option<String>)>
Get raw blob with delta source info for sync Returns (raw_content, size, delta_source_hash)
Sourcepub fn insert_raw_blob(
&self,
content: &[u8],
hash: &str,
size: i64,
) -> Result<i64>
pub fn insert_raw_blob( &self, content: &[u8], hash: &str, size: i64, ) -> Result<i64>
Insert a raw blob directly (for sync - content already compressed)
Sourcepub fn get_delta_source(&self, rid: i64) -> Result<Option<i64>>
pub fn get_delta_source(&self, rid: i64) -> Result<Option<i64>>
Check if blob is a delta, return source rid if so
Sourcepub fn get_hash_by_rid(&self, rid: i64) -> Result<String>
pub fn get_hash_by_rid(&self, rid: i64) -> Result<String>
Get hash by rid
Sourcepub fn get_rid_by_hash(&self, hash: &str) -> Result<i64>
pub fn get_rid_by_hash(&self, hash: &str) -> Result<i64>
Get rid by hash (supports prefix matching)
Sourcepub fn get_project_code(&self) -> Result<String>
pub fn get_project_code(&self) -> Result<String>
Get project code
Sourcepub fn get_project_name(&self) -> Result<Option<String>>
pub fn get_project_name(&self) -> Result<Option<String>>
Get project name
Sourcepub fn get_trunk_tip(&self) -> Result<i64>
pub fn get_trunk_tip(&self) -> Result<i64>
Get latest check-in on trunk
Sourcepub fn get_branch_tip(&self, branch: &str) -> Result<i64>
pub fn get_branch_tip(&self, branch: &str) -> Result<i64>
Get check-in by branch name
Sourcepub fn list_branches(&self) -> Result<Vec<String>>
pub fn list_branches(&self) -> Result<Vec<String>>
List all branches
Sourcepub fn get_recent_checkins(
&self,
limit: usize,
) -> Result<Vec<(i64, String, f64, String, String)>>
pub fn get_recent_checkins( &self, limit: usize, ) -> Result<Vec<(i64, String, f64, String, String)>>
Get recent check-ins
pub fn connection(&self) -> &Connection
Sourcepub fn generate_hash(data: &[u8]) -> String
pub fn generate_hash(data: &[u8]) -> String
Generate SHA3-256 hash
Sourcepub fn insert_blob(&self, content: &[u8], hash: &str, size: i64) -> Result<i64>
pub fn insert_blob(&self, content: &[u8], hash: &str, size: i64) -> Result<i64>
Insert a blob and return its rid (uses INSERT OR IGNORE for efficiency)
Sourcepub fn insert_blobs(
&self,
blobs: &[(&[u8], &str, i64)],
) -> Result<HashMap<String, i64>>
pub fn insert_blobs( &self, blobs: &[(&[u8], &str, i64)], ) -> Result<HashMap<String, i64>>
Batch insert blobs and return a map of hash -> rid Uses cached prepared statements for efficiency
Sourcepub fn get_or_create_filename(&self, name: &str) -> Result<i64>
pub fn get_or_create_filename(&self, name: &str) -> Result<i64>
Get or create filename id
Sourcepub fn get_or_create_filenames(
&self,
names: &[&str],
) -> Result<HashMap<String, i64>>
pub fn get_or_create_filenames( &self, names: &[&str], ) -> Result<HashMap<String, i64>>
Batch insert filenames and return a map of name -> fnid Uses cached prepared statements for efficiency
Sourcepub fn get_or_create_tag(&self, tagname: &str) -> Result<i64>
pub fn get_or_create_tag(&self, tagname: &str) -> Result<i64>
Get or create tag id
Sourcepub fn insert_event(
&self,
event_type: &str,
objid: i64,
mtime: f64,
user: &str,
comment: &str,
) -> Result<()>
pub fn insert_event( &self, event_type: &str, objid: i64, mtime: f64, user: &str, comment: &str, ) -> Result<()>
Insert event record
Sourcepub fn insert_tagxref(
&self,
tagid: i64,
tagtype: i64,
rid: i64,
mtime: f64,
value: Option<&str>,
) -> Result<()>
pub fn insert_tagxref( &self, tagid: i64, tagtype: i64, rid: i64, mtime: f64, value: Option<&str>, ) -> Result<()>
Insert tagxref record
Sourcepub fn insert_leaf(&self, rid: i64) -> Result<()>
pub fn insert_leaf(&self, rid: i64) -> Result<()>
Insert a leaf node
Sourcepub fn insert_plink(
&self,
parent_rid: i64,
child_rid: i64,
mtime: f64,
) -> Result<()>
pub fn insert_plink( &self, parent_rid: i64, child_rid: i64, mtime: f64, ) -> Result<()>
Insert plink (parent link) record and update leaf table
Sourcepub fn get_files_for_manifest(
&self,
manifest_rid: i64,
) -> Result<Vec<(String, String)>>
pub fn get_files_for_manifest( &self, manifest_rid: i64, ) -> Result<Vec<(String, String)>>
Get all files for a manifest (checkin) directly from mlink table Returns (filename, file_hash) pairs
Sourcepub fn get_file_hash_from_manifest(
&self,
manifest_rid: i64,
filename: &str,
) -> Result<String>
pub fn get_file_hash_from_manifest( &self, manifest_rid: i64, filename: &str, ) -> Result<String>
Get a single file’s hash from a manifest by filename
Sourcepub fn insert_mlink(
&self,
manifest_rid: i64,
file_rid: i64,
filename_id: i64,
parent_file_rid: Option<i64>,
) -> Result<()>
pub fn insert_mlink( &self, manifest_rid: i64, file_rid: i64, filename_id: i64, parent_file_rid: Option<i64>, ) -> Result<()>
Insert mlink (manifest link) record
Sourcepub fn insert_mlinks(
&self,
manifest_rid: i64,
entries: &[(i64, i64)],
) -> Result<()>
pub fn insert_mlinks( &self, manifest_rid: i64, entries: &[(i64, i64)], ) -> Result<()>
Batch insert mlink records using cached prepared statement
Sourcepub fn create_user(
&self,
login: &str,
password: &str,
capabilities: &str,
) -> Result<()>
pub fn create_user( &self, login: &str, password: &str, capabilities: &str, ) -> Result<()>
Create a user
Sourcepub fn set_user_capabilities(
&self,
login: &str,
capabilities: &str,
) -> Result<()>
pub fn set_user_capabilities( &self, login: &str, capabilities: &str, ) -> Result<()>
Set user capabilities
Sourcepub fn get_user_capabilities(&self, login: &str) -> Result<Option<String>>
pub fn get_user_capabilities(&self, login: &str) -> Result<Option<String>>
Get user capabilities
Sourcepub fn begin_transaction(&self) -> Result<()>
pub fn begin_transaction(&self) -> Result<()>
Begin transaction
Sourcepub fn commit_transaction(&self) -> Result<()>
pub fn commit_transaction(&self) -> Result<()>
Commit transaction
Sourcepub fn rollback_transaction(&self) -> Result<()>
pub fn rollback_transaction(&self) -> Result<()>
Rollback transaction