pub struct PullsHandler<'a> { /* private fields */ }
Expand description
A client for the Pull Request API.
Implementations§
Source§impl<'a> PullsHandler<'a>
impl<'a> PullsHandler<'a>
pub fn new( client: &'a Client, owner: impl Into<String>, repo: impl Into<String>, ) -> PullsHandler<'_>
Sourcepub fn list(&self) -> ListPullRequestsBuilder<'_>
pub fn list(&self) -> ListPullRequestsBuilder<'_>
List pull requests.
See https://docs.github.com/en/rest/reference/pulls#list-pull-requests.
let client = ghrs::Client::new();
let pull_requests = client.pulls("owner", "repo").list().per_page(100).send();
Examples found in repository?
examples/pr_triage.rs (line 13)
5fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
6 let args: Vec<String> = std::env::args().collect();
7 let owner = args.get(1).unwrap();
8 let repo = args.get(2).unwrap();
9
10 let client = Client::new();
11 let mut current_page = client
12 .pulls(owner, repo)
13 .list()
14 .sort("updated")
15 .direction("desc")
16 .per_page(100)
17 .page(1)
18 .send()?;
19
20 let mut pull_requests = current_page.take_items();
21
22 while let Some(next_page) = current_page.get_next_page() {
23 current_page = next_page;
24 pull_requests.extend(current_page.take_items());
25 }
26
27 let earlier_than = Utc::now() - Duration::days(14);
28 let pull_requests = pull_requests
29 .into_iter()
30 .filter(|x| x.updated_at.unwrap() < earlier_than);
31 println!("## Triaged Pull Requests");
32 for pull_request in pull_requests {
33 println!("- [{}]({})", pull_request.title, pull_request.html_url);
34 }
35
36 Ok(())
37}
Sourcepub fn get(&self, pull_number: u64) -> GetPullRequestBuilder<'_>
pub fn get(&self, pull_number: u64) -> GetPullRequestBuilder<'_>
Get a pull request.
See https://docs.github.com/en/rest/reference/pulls#get-a-pull-request.
let client = ghrs::Client::new();
let pull_request = client.pulls("owner", "repo").get(1234).send();
Auto Trait Implementations§
impl<'a> Freeze for PullsHandler<'a>
impl<'a> RefUnwindSafe for PullsHandler<'a>
impl<'a> Send for PullsHandler<'a>
impl<'a> Sync for PullsHandler<'a>
impl<'a> Unpin for PullsHandler<'a>
impl<'a> UnwindSafe for PullsHandler<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more