Skip to main content

GithubClient

Struct GithubClient 

Source
pub struct GithubClient { /* private fields */ }
Expand description

Sync GitHub Releases API client.

Constructed with an explicit base URL (for test injection via mockito) and an optional bearer token. Does not read environment variables in the constructor — use from_env() for that.

Implementations§

Source§

impl GithubClient

Source

pub fn new(base_url: &str, user_agent: &str, token: Option<String>) -> Self

Create a client with an explicit token (or None for unauthenticated).

Tests use this constructor directly to avoid touching process-global env state.

Source

pub fn from_env(base_url: &str, user_agent: &str) -> Self

Create a client reading auth from the environment.

Precedence: GITHUB_TOKEN wins when both are set, matching gh CLI’s default non-enterprise behavior.

Source

pub fn latest_release_tag(&self, org: &str, repo: &str) -> Result<String, Error>

Fetch the latest (most recently published, non-draft) release tag.

Uses the list endpoint (/repos/{org}/{repo}/releases) rather than /releases/latest so that pre-release tags are visible.

Source

pub fn release_asset_body( &self, org: &str, repo: &str, tag: &str, ) -> Result<(u64, Box<dyn Read + Send>), Error>

Stream the first .tar.gz asset for a given release tag.

Returns (content_length, reader). The reader is the raw HTTP body; the caller wraps it in a progress bar and hands it to tarball::extract_safe.

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V