Struct GitHubApi

Source
pub struct GitHubApi { /* private fields */ }

Implementations§

Source§

impl GitHubApi

Implement basic functionality.

Source

pub fn new(username: &str, password: &str) -> Self

Examples found in repository?
examples/get_rate_limit.rs (line 15)
11fn main() {
12    let username = env::var("GH_USER").expect("GH_USER not defined.");
13    let password = env::var("GH_PASS").expect("GH_PASS not defined.");
14
15    let gh = GitHubApi::new(&username, &password);
16
17    let result = gh.get_rate_limit();
18    println!("{:#?}", result);
19}
More examples
Hide additional examples
examples/get_tags.rs (line 15)
11fn main() {
12    let username = env::var("GH_USER").expect("GH_USER not defined.");
13    let password = env::var("GH_PASS").expect("GH_PASS not defined.");
14
15    let gh = GitHubApi::new(&username, &password);
16
17    for page in gh.get_tags("postgres", "postgres") {
18        println!("{:#?}", page);
19    }
20}
examples/get_license.rs (line 15)
11fn main() {
12    let username = env::var("GH_USER").expect("GH_USER not defined.");
13    let password = env::var("GH_PASS").expect("GH_PASS not defined.");
14
15    let gh = GitHubApi::new(&username, &password);
16
17    let license = gh.get_license("sous-chefs", "postgresql");
18    println!("{:#?}", license);
19}
examples/get_releases.rs (line 15)
11fn main() {
12    let username = env::var("GH_USER").expect("GH_USER not defined.");
13    let password = env::var("GH_PASS").expect("GH_PASS not defined.");
14
15    let gh = GitHubApi::new(&username, &password);
16
17    for page in gh.get_releases("sous-chefs", "postgresql") {
18        println!("{:#?}", page);
19    }
20}
examples/get_license_as_json_string.rs (line 15)
11fn main() {
12    let username = env::var("GH_USER").expect("GH_USER not defined.");
13    let password = env::var("GH_PASS").expect("GH_PASS not defined.");
14
15    let gh = GitHubApi::new(&username, &password);
16
17    let license = gh.get_license("sous-chefs", "postgresql");
18    println!("{:#?}", license.unwrap().result.to_json_string());
19}
examples/get_releases_or_tags.rs (line 15)
11fn main() {
12    let username = env::var("GH_USER").expect("GH_USER not defined.");
13    let password = env::var("GH_PASS").expect("GH_PASS not defined.");
14
15    let gh = GitHubApi::new(&username, &password);
16
17    let owner = "rabbitmq";
18    let repository = "rabbitmq-server";
19
20    let releases_paginator = gh.get_releases(owner, repository);
21
22    match releases_paginator.has_items() {
23        Ok(true) => {
24            println!("There are releases. Get them.");
25
26            // for page in releases_paginator {
27            //     println!("{:#?}", page);
28            // }
29        }
30
31        Ok(false) => {
32            println!("There are no releases. Get the tags instead.");
33
34            // for page in gh.get_tags(owner, repository) {
35            //     println!("{:#?}", page);
36            // }
37        }
38
39        Err(error) => {
40            println!("There was a problem: {:#?}.", error);
41        }
42    }
43}
Source§

impl GitHubApi

Implement rate limits.

Source

pub fn get_rate_limit( &self, ) -> Result<GitHubApiResult<RateLimitResponse>, GitHubApiError>

Gets rate limit information.

Examples found in repository?
examples/get_rate_limit.rs (line 17)
11fn main() {
12    let username = env::var("GH_USER").expect("GH_USER not defined.");
13    let password = env::var("GH_PASS").expect("GH_PASS not defined.");
14
15    let gh = GitHubApi::new(&username, &password);
16
17    let result = gh.get_rate_limit();
18    println!("{:#?}", result);
19}
Source§

impl GitHubApi

Source

pub fn get_license( &self, owner: &str, repository: &str, ) -> Result<GitHubApiResult<LicenseResponse>, GitHubApiError>

Gets the page.

Examples found in repository?
examples/get_license.rs (line 17)
11fn main() {
12    let username = env::var("GH_USER").expect("GH_USER not defined.");
13    let password = env::var("GH_PASS").expect("GH_PASS not defined.");
14
15    let gh = GitHubApi::new(&username, &password);
16
17    let license = gh.get_license("sous-chefs", "postgresql");
18    println!("{:#?}", license);
19}
More examples
Hide additional examples
examples/get_license_as_json_string.rs (line 17)
11fn main() {
12    let username = env::var("GH_USER").expect("GH_USER not defined.");
13    let password = env::var("GH_PASS").expect("GH_PASS not defined.");
14
15    let gh = GitHubApi::new(&username, &password);
16
17    let license = gh.get_license("sous-chefs", "postgresql");
18    println!("{:#?}", license.unwrap().result.to_json_string());
19}
Source§

impl GitHubApi

Source

pub fn get_tags_page( &self, owner: &str, repository: &str, page: u64, ) -> Result<GitHubApiResult<Vec<TagsResponse>>, GitHubApiError>

Gets a single page.

Source

pub fn get_tags(&self, owner: &str, repository: &str) -> TagPaginator<'_>

Creates a paginator.

Examples found in repository?
examples/get_tags.rs (line 17)
11fn main() {
12    let username = env::var("GH_USER").expect("GH_USER not defined.");
13    let password = env::var("GH_PASS").expect("GH_PASS not defined.");
14
15    let gh = GitHubApi::new(&username, &password);
16
17    for page in gh.get_tags("postgres", "postgres") {
18        println!("{:#?}", page);
19    }
20}
Source§

impl GitHubApi

Source

pub fn get_releases_page( &self, owner: &str, repository: &str, page: u64, ) -> Result<GitHubApiResult<Vec<ReleasesResponse>>, GitHubApiError>

Gets a single page.

Source

pub fn get_releases( &self, owner: &str, repository: &str, ) -> ReleasePaginator<'_>

Creates a paginator.

Examples found in repository?
examples/get_releases.rs (line 17)
11fn main() {
12    let username = env::var("GH_USER").expect("GH_USER not defined.");
13    let password = env::var("GH_PASS").expect("GH_PASS not defined.");
14
15    let gh = GitHubApi::new(&username, &password);
16
17    for page in gh.get_releases("sous-chefs", "postgresql") {
18        println!("{:#?}", page);
19    }
20}
More examples
Hide additional examples
examples/get_releases_or_tags.rs (line 20)
11fn main() {
12    let username = env::var("GH_USER").expect("GH_USER not defined.");
13    let password = env::var("GH_PASS").expect("GH_PASS not defined.");
14
15    let gh = GitHubApi::new(&username, &password);
16
17    let owner = "rabbitmq";
18    let repository = "rabbitmq-server";
19
20    let releases_paginator = gh.get_releases(owner, repository);
21
22    match releases_paginator.has_items() {
23        Ok(true) => {
24            println!("There are releases. Get them.");
25
26            // for page in releases_paginator {
27            //     println!("{:#?}", page);
28            // }
29        }
30
31        Ok(false) => {
32            println!("There are no releases. Get the tags instead.");
33
34            // for page in gh.get_tags(owner, repository) {
35            //     println!("{:#?}", page);
36            // }
37        }
38
39        Err(error) => {
40            println!("There was a problem: {:#?}.", error);
41        }
42    }
43}

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Err = <U as TryFrom<T>>::Err

Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Err>

Source§

impl<T> ErasedDestructor for T
where T: 'static,