pub struct GitHub { /* private fields */ }
Expand description

Struct to communicate with the GitHub REST API.

Implementations

Create a new instance of the struct suitable for public GitHub.

The struct created by this function does not set an access token and as such can only get information on public GitHub repositories.

If you need to access information for private repositories or any information from a custom GitHub enterprise instance, use the from_custom function.

This function may return an Error if the HTTP client could not be constructed or headers initialized. It should be safe to unwrap the Result.

Example
use github_release_check::GitHub;
let github = GitHub::new().unwrap();

Create a new instance of the struct suitable for accessing any GitHub repository that can be viewed with the access key on the GitHub instance.

This function has to be used to construct the struct instance whenever the repository that you want to get information from is on a custom GitHub enterprise instance and/or is private. The access token passed to this function should be a GitHub personal access token that has the access to view the repository on that GitHub instance.

For the api_endpoint argument, pass in the REST API root of the GitHub instance. For public GitHub, this can be found in DEFAULT_API_ROOT. Your GitHub enterprise may use a subdomain like "https://api.github.your_domain_root.com/", or perhaps something like "https://github.your_domain_root.com/api/v3/". Specify the API root that you can otherwise send requests to. Note that this URL should end in a trailing slash.

Example
use github_release_check::GitHub;
let github = GitHub::from_custom("https://github.example.com/api/v3/", "abcdef").unwrap();

Get all release versions from the repository.

Just like get_latest_version but instead returns all the versions in case you need them.

Actually called by get_latest_version under the hood.

Example
use github_release_check::GitHub;
let github = GitHub::new().unwrap();
let versions_result = github.get_all_versions("celeo/github_release_check");

Get the latest release version from the repository.

Note that repository should be in the format “owner/repo”, like "celeo/github_release_check".

As this function needs to select and return the latest release version, it makes use of the “semver” crate’s Version parse function. As there’s no requirement for repositories to use Semantic Versioning, this function may not suitable for every repository (thus the get_all_versions function which just works with Strings).

A leading 'v' character is stripped from the versions in order to make more repositories work. For any version string that is not able to be loaded into a Version struct, it is skipped. Note that this may result in no or missing versions.

Effectively, for repositories that are using Semantic Versioning correctly, this will work. For those that are not, it’s a bit of a toss-up.

Since this call can fail for a number of reasons including anything related to the network at the time of the call, the Result from this function should be handled appropriately.

Example
use github_release_check::GitHub;
let github = GitHub::new().unwrap();
let version_result = github.get_latest_version("celeo/github_release_check");

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more