Struct PullsHandler

Source
pub struct PullsHandler<'a> { /* private fields */ }
Expand description

A client for the Pull Request API.

See https://docs.github.com/en/rest/reference/pulls.

Implementations§

Source§

impl<'a> PullsHandler<'a>

Source

pub fn new( client: &'a Client, owner: impl Into<String>, repo: impl Into<String>, ) -> PullsHandler<'_>

Source

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

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> 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, 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.