Database

Struct Database 

Source
pub struct Database { /* private fields */ }

Implementations§

Source§

impl Database

Source

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>

Open a Heroforge repository database (read-only)

Source

pub fn open_rw<P: AsRef<Path>>(path: P) -> Result<Self>

Open for read-write

Source

pub fn get_blob_raw(&self, hash: &str) -> Result<(i64, Vec<u8>)>

Get raw blob content by hash (still compressed)

Source

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)

Source

pub fn insert_raw_blob( &self, content: &[u8], hash: &str, size: i64, ) -> Result<i64>

Insert a raw blob directly (for sync - content already compressed)

Source

pub fn insert_delta(&self, rid: i64, src_rid: i64) -> Result<()>

Insert delta reference

Source

pub fn get_blob_by_rid(&self, rid: i64) -> Result<Vec<u8>>

Get blob content by rid

Source

pub fn get_delta_source(&self, rid: i64) -> Result<Option<i64>>

Check if blob is a delta, return source rid if so

Source

pub fn get_hash_by_rid(&self, rid: i64) -> Result<String>

Get hash by rid

Source

pub fn get_rid_by_hash(&self, hash: &str) -> Result<i64>

Get rid by hash (supports prefix matching)

Source

pub fn get_project_code(&self) -> Result<String>

Get project code

Source

pub fn get_project_name(&self) -> Result<Option<String>>

Get project name

Source

pub fn get_trunk_tip(&self) -> Result<i64>

Get latest check-in on trunk

Source

pub fn get_branch_tip(&self, branch: &str) -> Result<i64>

Get check-in by branch name

Source

pub fn list_branches(&self) -> Result<Vec<String>>

List all branches

Source

pub fn get_recent_checkins( &self, limit: usize, ) -> Result<Vec<(i64, String, f64, String, String)>>

Get recent check-ins

Source

pub fn connection(&self) -> &Connection

Source

pub fn init<P: AsRef<Path>>(path: P) -> Result<Self>

Create a new empty Heroforge repository

Source

pub fn generate_hash(data: &[u8]) -> String

Generate SHA3-256 hash

Source

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)

Source

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

Source

pub fn get_or_create_filename(&self, name: &str) -> Result<i64>

Get or create filename id

Source

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

Source

pub fn get_or_create_tag(&self, tagname: &str) -> Result<i64>

Get or create tag id

Source

pub fn insert_event( &self, event_type: &str, objid: i64, mtime: f64, user: &str, comment: &str, ) -> Result<()>

Insert event record

Source

pub fn insert_tagxref( &self, tagid: i64, tagtype: i64, rid: i64, mtime: f64, value: Option<&str>, ) -> Result<()>

Insert tagxref record

Source

pub fn insert_leaf(&self, rid: i64) -> Result<()>

Insert a leaf node

Insert plink (parent link) record and update leaf table

Source

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

Source

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

Insert mlink (manifest link) record

Batch insert mlink records using cached prepared statement

Source

pub fn create_user( &self, login: &str, password: &str, capabilities: &str, ) -> Result<()>

Create a user

Source

pub fn set_user_capabilities( &self, login: &str, capabilities: &str, ) -> Result<()>

Set user capabilities

Source

pub fn get_user_capabilities(&self, login: &str) -> Result<Option<String>>

Get user capabilities

Source

pub fn list_users(&self) -> Result<Vec<(String, String)>>

List all users

Source

pub fn begin_transaction(&self) -> Result<()>

Begin transaction

Source

pub fn commit_transaction(&self) -> Result<()>

Commit transaction

Source

pub fn rollback_transaction(&self) -> Result<()>

Rollback transaction

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.