Skip to main content

commit_bridge/repository/
branch.rs

1//! Repository access for the `branches` table.
2
3use crate::model::Branch;
4use crate::repository::RepositoryError;
5use async_trait::async_trait;
6
7/// Interface for `branches` table operations.
8#[async_trait]
9pub trait BranchRepository: Send + Sync {
10    /// Returns all branches.
11    async fn get_all(&self) -> Result<Vec<Branch>, RepositoryError>;
12
13    /// Returns the branch with the given `id`.
14    async fn find_by_id(&self, id: i64) -> Result<Option<Branch>, RepositoryError>;
15
16    /// Deletes the branch with the given `id`.
17    async fn delete_by_id(&self, id: i64) -> Result<(), RepositoryError>;
18
19    /// Updates the last commit hash of the branch.
20    async fn update_last_commit_hash(
21        &self,
22        id: i64,
23        hash: &crate::domain::CommitHash,
24    ) -> Result<(), RepositoryError>;
25
26    /// Updates the last commit hash of the branch within a transaction.
27    async fn update_last_commit_hash_in_tx(
28        &self,
29        id: i64,
30        hash: &crate::domain::CommitHash,
31        tx: &mut sqlx::SqliteConnection,
32    ) -> Result<(), RepositoryError>;
33}