| 1 | use super::RepositoryResult; |
| 2 | use crate::domain::{Issue, IssueComment, IssueId, IssueNumber, IssueState, RepoId}; |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | #[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] |
| 9 | pub struct IssueCounts { |
| 10 | pub open: u64, |
| 11 | pub closed: u64, |
| 12 | } |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | pub trait IssueRepository: Send + Sync { |
| 21 | |
| 22 | fn find_by_number( |
| 23 | &self, |
| 24 | repo_id: &RepoId, |
| 25 | number: IssueNumber, |
| 26 | ) -> impl Future<Output = RepositoryResult<Option<Issue>>> + Send; |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | fn list_by_repo( |
| 40 | &self, |
| 41 | repo_id: &RepoId, |
| 42 | state: IssueState, |
| 43 | offset: usize, |
| 44 | limit: usize, |
| 45 | ) -> impl Future<Output = RepositoryResult<Vec<Issue>>> + Send; |
| 46 | |
| 47 | |
| 48 | fn counts( |
| 49 | &self, |
| 50 | repo_id: &RepoId, |
| 51 | ) -> impl Future<Output = RepositoryResult<IssueCounts>> + Send; |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | fn comment_counts( |
| 58 | &self, |
| 59 | repo_id: &RepoId, |
| 60 | ) -> impl Future<Output = RepositoryResult<Vec<(IssueId, u64)>>> + Send; |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | fn save(&self, issue: &Issue) -> impl Future<Output = RepositoryResult<()>> + Send; |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | fn list_comments( |
| 73 | &self, |
| 74 | issue_id: &IssueId, |
| 75 | ) -> impl Future<Output = RepositoryResult<Vec<IssueComment>>> + Send; |
| 76 | |
| 77 | |
| 78 | fn add_comment( |
| 79 | &self, |
| 80 | comment: &IssueComment, |
| 81 | ) -> impl Future<Output = RepositoryResult<()>> + Send; |
| 82 | } |