pub trait GitHubApi: Send + Sync {
// Required methods
fn get_pr(
&self,
owner: &str,
repo: &str,
number: u64,
) -> impl Future<Output = Result<PullRequest>> + Send;
fn get_prs_batch(
&self,
owner: &str,
repo: &str,
numbers: &[u64],
) -> impl Future<Output = Result<HashMap<u64, PullRequest>>> + Send;
fn find_pr_for_branch(
&self,
owner: &str,
repo: &str,
branch: &str,
) -> impl Future<Output = Result<Option<PullRequest>>> + Send;
fn create_pr(
&self,
owner: &str,
repo: &str,
pr: CreatePullRequest,
) -> impl Future<Output = Result<PullRequest>> + Send;
fn update_pr(
&self,
owner: &str,
repo: &str,
number: u64,
update: UpdatePullRequest,
) -> impl Future<Output = Result<PullRequest>> + Send;
fn get_check_runs(
&self,
owner: &str,
repo: &str,
commit_sha: &str,
) -> impl Future<Output = Result<Vec<CheckRun>>> + Send;
fn merge_pr(
&self,
owner: &str,
repo: &str,
number: u64,
merge: MergePullRequest,
) -> impl Future<Output = Result<MergeResult>> + Send;
fn delete_ref(
&self,
owner: &str,
repo: &str,
ref_name: &str,
) -> impl Future<Output = Result<()>> + Send;
fn get_default_branch(
&self,
owner: &str,
repo: &str,
) -> impl Future<Output = Result<String>> + Send;
fn list_pr_comments(
&self,
owner: &str,
repo: &str,
pr_number: u64,
) -> impl Future<Output = Result<Vec<IssueComment>>> + Send;
fn create_pr_comment(
&self,
owner: &str,
repo: &str,
pr_number: u64,
comment: CreateComment,
) -> impl Future<Output = Result<IssueComment>> + Send;
fn update_pr_comment(
&self,
owner: &str,
repo: &str,
comment_id: u64,
comment: UpdateComment,
) -> impl Future<Output = Result<IssueComment>> + Send;
}Expand description
Trait for GitHub API operations.
This trait abstracts GitHub API calls, allowing for:
- Dependency injection in commands/services
- Mock implementations for testing
- Alternative implementations (e.g., offline mode, caching)
All methods take owner and repo as parameters to support
operations across different repositories.
Required Methods§
Sourcefn get_pr(
&self,
owner: &str,
repo: &str,
number: u64,
) -> impl Future<Output = Result<PullRequest>> + Send
fn get_pr( &self, owner: &str, repo: &str, number: u64, ) -> impl Future<Output = Result<PullRequest>> + Send
Get a pull request by number.
Sourcefn get_prs_batch(
&self,
owner: &str,
repo: &str,
numbers: &[u64],
) -> impl Future<Output = Result<HashMap<u64, PullRequest>>> + Send
fn get_prs_batch( &self, owner: &str, repo: &str, numbers: &[u64], ) -> impl Future<Output = Result<HashMap<u64, PullRequest>>> + Send
Get multiple pull requests by number (batch operation).
Returns a map of PR number to PR data. Missing PRs are omitted.
Sourcefn find_pr_for_branch(
&self,
owner: &str,
repo: &str,
branch: &str,
) -> impl Future<Output = Result<Option<PullRequest>>> + Send
fn find_pr_for_branch( &self, owner: &str, repo: &str, branch: &str, ) -> impl Future<Output = Result<Option<PullRequest>>> + Send
Find a PR for a branch.
Returns None if no open PR exists for the branch.
Sourcefn create_pr(
&self,
owner: &str,
repo: &str,
pr: CreatePullRequest,
) -> impl Future<Output = Result<PullRequest>> + Send
fn create_pr( &self, owner: &str, repo: &str, pr: CreatePullRequest, ) -> impl Future<Output = Result<PullRequest>> + Send
Create a pull request.
Sourcefn update_pr(
&self,
owner: &str,
repo: &str,
number: u64,
update: UpdatePullRequest,
) -> impl Future<Output = Result<PullRequest>> + Send
fn update_pr( &self, owner: &str, repo: &str, number: u64, update: UpdatePullRequest, ) -> impl Future<Output = Result<PullRequest>> + Send
Update a pull request.
Sourcefn get_check_runs(
&self,
owner: &str,
repo: &str,
commit_sha: &str,
) -> impl Future<Output = Result<Vec<CheckRun>>> + Send
fn get_check_runs( &self, owner: &str, repo: &str, commit_sha: &str, ) -> impl Future<Output = Result<Vec<CheckRun>>> + Send
Get check runs for a commit.
Sourcefn merge_pr(
&self,
owner: &str,
repo: &str,
number: u64,
merge: MergePullRequest,
) -> impl Future<Output = Result<MergeResult>> + Send
fn merge_pr( &self, owner: &str, repo: &str, number: u64, merge: MergePullRequest, ) -> impl Future<Output = Result<MergeResult>> + Send
Merge a pull request.
Sourcefn delete_ref(
&self,
owner: &str,
repo: &str,
ref_name: &str,
) -> impl Future<Output = Result<()>> + Send
fn delete_ref( &self, owner: &str, repo: &str, ref_name: &str, ) -> impl Future<Output = Result<()>> + Send
Delete a git reference (branch).
Sourcefn get_default_branch(
&self,
owner: &str,
repo: &str,
) -> impl Future<Output = Result<String>> + Send
fn get_default_branch( &self, owner: &str, repo: &str, ) -> impl Future<Output = Result<String>> + Send
Get the repository’s default branch name.
Sourcefn list_pr_comments(
&self,
owner: &str,
repo: &str,
pr_number: u64,
) -> impl Future<Output = Result<Vec<IssueComment>>> + Send
fn list_pr_comments( &self, owner: &str, repo: &str, pr_number: u64, ) -> impl Future<Output = Result<Vec<IssueComment>>> + Send
List comments on a pull request.
Sourcefn create_pr_comment(
&self,
owner: &str,
repo: &str,
pr_number: u64,
comment: CreateComment,
) -> impl Future<Output = Result<IssueComment>> + Send
fn create_pr_comment( &self, owner: &str, repo: &str, pr_number: u64, comment: CreateComment, ) -> impl Future<Output = Result<IssueComment>> + Send
Create a comment on a pull request.
Sourcefn update_pr_comment(
&self,
owner: &str,
repo: &str,
comment_id: u64,
comment: UpdateComment,
) -> impl Future<Output = Result<IssueComment>> + Send
fn update_pr_comment( &self, owner: &str, repo: &str, comment_id: u64, comment: UpdateComment, ) -> impl Future<Output = Result<IssueComment>> + Send
Update a comment on a pull request.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.