pub struct GitHubSource { /* private fields */ }Expand description
A Source which lists and downloads releases from a GitHub repository’s
releases API.
The asset to download is selected by matching a glob pattern against each
release’s asset file names, so your project can name its release assets
however it likes — there is no required naming scheme. The pattern is the
second argument to new:
use std::env::consts::{ARCH, EXE_SUFFIX, OS};
use update_rs::GitHubSource;
let source = GitHubSource::new(
"sierrasoftworks/git-tool",
format!("git-tool-{OS}-{ARCH}{EXE_SUFFIX}"),
)
.with_release_tag_prefix("v");The naming helpers build common patterns for you, e.g.
naming::go (git-tool-linux-amd64) or
naming::rust (git-tool-x86_64-unknown-linux-gnu).
The pattern must match the asset’s whole file name (it is anchored at
both ends), so an exact name won’t accidentally select a .sha256 checksum
or .sig sidecar. It supports * (any sequence) and ? (single character)
wildcards; every other character matches literally. release_tag_prefix is
stripped from each Git tag before it is parsed as a
semantic version, and tags that don’t parse afterwards are
ignored.
When GitHub reports a SHA-256 digest for an asset, the downloaded bytes are verified against it before the update proceeds, so a corrupted or tampered download is rejected.
Implementations§
Source§impl GitHubSource
impl GitHubSource
Sourcepub fn new(repo: impl Into<String>, asset_pattern: impl Into<String>) -> Self
pub fn new(repo: impl Into<String>, asset_pattern: impl Into<String>) -> Self
Create a source for the owner/name repo (e.g.
"sierrasoftworks/git-tool"), selecting the asset to download with the
glob asset_pattern (e.g. "git-tool-linux-amd64" or "*-linux-amd64").
See the naming module for helpers that build a pattern
for the current platform.
Sourcepub fn with_client(self, client: Client) -> Self
pub fn with_client(self, client: Client) -> Self
Use a caller-provided reqwest::Client for every request instead of the
crate’s default.
This lets the consuming application apply its own client configuration —
proxy, TLS, timeouts, a custom User-Agent, default authentication
headers, and so on. The crate does not add its own User-Agent to a
caller-supplied client, so the client should set one itself (GitHub
requires a User-Agent on every request), for example via
reqwest::ClientBuilder::user_agent.
Sourcepub fn with_release_tag_prefix(self, prefix: &str) -> Self
pub fn with_release_tag_prefix(self, prefix: &str) -> Self
Strip prefix from each release’s Git tag before parsing it as a
semantic version (e.g. "v" for vX.Y.Z tags).
Sourcepub fn with_github_endpoints(self, web: &str, api: &str) -> Self
pub fn with_github_endpoints(self, web: &str, api: &str) -> Self
Override the GitHub web (web) and API (api) endpoints. This is
primarily useful for pointing the source at a GitHub Enterprise instance
or a mock server in tests. Trailing slashes are trimmed.
Trait Implementations§
Source§impl Debug for GitHubSource
impl Debug for GitHubSource
Source§impl Default for GitHubSource
impl Default for GitHubSource
Source§impl Source for GitHubSource
impl Source for GitHubSource
Source§fn get_releases<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Release>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_releases<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Release>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Release::variant.