Skip to main content

GitBackend

Struct GitBackend 

Source
pub struct GitBackend { /* private fields */ }
Expand description

Git-backed storage backend.

Directory layout:

{root}/
  metadata.yaml          — store name, features, ID config, etc.
  objects/
    FR/000/FR-001.yaml   — individual requirement files (sharded)
    BUG/000/BUG-001.yaml
  relations/             — (future: append-only relation log)
  registry/              — (future: node/user registries)

Implementations§

Source§

impl GitBackend

Source

pub fn new(root: &Path) -> Result<Self>

Create a new git backend rooted at the given directory. Creates the directory structure if it doesn’t exist.

Source

pub fn with_dispenser(self, dispenser: DispenserHandle) -> Self

Set the dispenser for ID generation (distributed mode).

Source

pub fn with_auto_commit(self, enabled: bool) -> Self

Disable auto-commit (useful for batch operations or testing).

Source

pub fn with_oplog(self, enabled: bool) -> Self

Enable or disable the operation log.

Trait Implementations§

Source§

impl DatabaseBackend for GitBackend

Source§

fn backend_type(&self) -> BackendType

Returns the backend type
Source§

fn path(&self) -> &Path

Returns the path to the database file
Source§

fn load(&self) -> Result<RequirementsStore>

Loads the entire requirements store from the database
Source§

fn save(&self, store: &RequirementsStore) -> Result<()>

Saves the entire requirements store to the database
Source§

fn get_requirement_by_spec_id( &self, spec_id: &str, ) -> Result<Option<Requirement>>

Gets a requirement by its spec_id (e.g., “FR-001”)
Source§

fn get_requirement(&self, id: &Uuid) -> Result<Option<Requirement>>

Gets a requirement by its UUID
Source§

fn update_requirement(&self, requirement: &Requirement) -> Result<()>

Updates an existing requirement
Source§

fn delete_requirement(&self, id: &Uuid) -> Result<()>

Deletes a requirement by UUID
Source§

fn add_requirement(&self, requirement: Requirement) -> Result<Requirement>

Adds a new requirement Returns the requirement with assigned spec_id Note: This uses the simple SPEC-XXX format for ID generation. For more complex ID generation (with feature/type prefixes), use update_atomically
Source§

fn exists(&self) -> bool

Returns true if the database file exists
Source§

fn update_atomically<F>(&self, update_fn: F) -> Result<RequirementsStore>
where F: FnOnce(&mut RequirementsStore), Self: Sized,

Performs an atomic update operation Default implementation loads, applies changes, and saves
Source§

fn list_requirements(&self, include_archived: bool) -> Result<Vec<Requirement>>

Lists all requirements (non-archived by default)
Source§

fn update_requirement_versioned( &self, requirement: &Requirement, ) -> Result<UpdateResult>

Updates a requirement with optimistic locking Read more
Source§

fn get_user(&self, id: &Uuid) -> Result<Option<User>>

Gets a user by UUID
Source§

fn get_user_by_handle(&self, handle: &str) -> Result<Option<User>>

Gets a user by handle
Source§

fn list_users(&self, include_archived: bool) -> Result<Vec<User>>

Lists all users
Source§

fn add_user(&self, user: User) -> Result<User>

Adds a new user
Source§

fn update_user(&self, user: &User) -> Result<()>

Updates an existing user
Source§

fn delete_user(&self, id: &Uuid) -> Result<()>

Deletes a user by UUID
Source§

fn get_name(&self) -> Result<String>

Gets the database name
Source§

fn set_name(&self, name: &str) -> Result<()>

Sets the database name
Source§

fn get_title(&self) -> Result<String>

Gets the database title
Source§

fn set_title(&self, title: &str) -> Result<()>

Sets the database title
Source§

fn get_description(&self) -> Result<String>

Gets the database description
Source§

fn set_description(&self, description: &str) -> Result<()>

Sets the database description
Source§

fn create_baseline( &self, name: String, description: Option<String>, created_by: String, ) -> Result<Baseline>

Creates a new baseline from current requirements For YAML backend, this also creates a git tag
Source§

fn list_baselines(&self) -> Result<Vec<Baseline>>

Lists all baselines
Source§

fn get_baseline(&self, id: &Uuid) -> Result<Option<Baseline>>

Gets a baseline by ID
Source§

fn delete_baseline(&self, id: &Uuid) -> Result<bool>

Deletes a baseline (if not locked)
Source§

fn compare_with_baseline( &self, baseline_id: &Uuid, ) -> Result<Option<BaselineComparison>>

Compares current state against a baseline
Source§

fn compare_baselines( &self, source_id: &Uuid, target_id: &Uuid, ) -> Result<Option<BaselineComparison>>

Compares two baselines
Source§

fn get_store_version(&self) -> Result<i64>

Gets the current store version (for detecting external modifications) Read more
Source§

fn create_if_not_exists(&self) -> Result<()>

Creates the database with default/empty data if it doesn’t exist
Source§

fn queue_list( &self, _user_id: &str, _include_completed: bool, ) -> Result<Vec<QueueEntry>>

Lists queue entries for a user If include_completed is false, excludes entries whose requirement is Completed
Source§

fn queue_add(&self, _entry: QueueEntry) -> Result<()>

Adds an entry to a user’s queue
Source§

fn queue_remove(&self, _user_id: &str, _requirement_id: &Uuid) -> Result<()>

Removes an entry from a user’s queue
Source§

fn queue_reorder(&self, _user_id: &str, _items: &[(Uuid, i64)]) -> Result<()>

Reorders queue entries by updating positions
Source§

fn queue_clear(&self, _user_id: &str, _completed_only: bool) -> Result<()>

Clears queue entries. If completed_only is true, only removes entries whose requirement has status Completed.
Source§

fn stats(&self) -> Result<DatabaseStats>

Returns statistics about the database

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.