Skip to main content

GitHubClient

Struct GitHubClient 

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

Implementations§

Source§

impl GitHubClient

Source

pub fn blame( &self, owner: &str, repo: &str, path: &str, ref_: Option<&str>, ) -> ProviderResult<Vec<BlameRange>>

Blame, derived client-side: GitHub’s GraphQL Blob.blame was removed from the schema (upstream drift, caught live 2026-08-28) and REST has none — so walk the file’s commit history newest-first and claim each commit’s ADDED hunks (the classic no-API approximation; intra-hunk moves and pre-window history are not distinguished). Bounded to COMMITS commit details — older lines carry no margin, honestly. Cached per (repo, path, ref) for the session.

Source§

impl GitHubClient

Source

pub fn blob_at( &self, owner: &str, repo: &str, path: &str, ref_: Option<&str>, ) -> ProviderResult<(Vec<u8>, String)>

File at a ref via the contents API: raw bytes + the git blob sha (the provider’s content id).

Source

pub fn source_tarball(&self, repo: &str) -> ProviderResult<Vec<u8>>

The default branch’s source as a gzip tarball (api.github.com 302s to codeload). Capped — a repo past this size is not a fallback candidate.

Source

pub fn fetch_blob( &self, owner: &str, repo: &str, sha: &str, ) -> ProviderResult<Vec<u8>>

Fetch a blob by git sha, cache-first (blobs are immutable). Files over 1 MiB are rejected — too heavy for a preview pane.

Source§

impl GitHubClient

Source

pub fn log( &self, owner: &str, repo: &str, path: Option<&str>, ref_: Option<&str>, limit: Option<usize>, ) -> ProviderResult<(Vec<LogEntry>, bool)>

Commit log newest-first. limit+1 probing decides truncated without parsing Link headers; a hard cap of 100 keeps it to one call (the spec’s ~N reading).

Source

pub fn commit( &self, owner: &str, repo: &str, sha: &str, ) -> ProviderResult<CommitResponse>

v1.6 (plans/0028 M1): one commit’s detail — message, parents, changed files with their unified hunks. The wire model is types::CommitResponse; the seam mapping lives in lib.rs.

Source§

impl GitHubClient

Source

pub fn refs(&self, owner: &str, repo: &str) -> ProviderResult<RepoRefs>

Branches (first 100) + tags (first 100); the repo’s default branch is marked. Refs past the cap are out of scope for a switcher.

Source§

impl GitHubClient

Source

pub fn search(&self, query: &str) -> ProviderResult<Vec<SearchItem>>

Repo search + org search, merged: orgs first, then repos. Returns provider-level items (the trait boundary type).

Examples found in repository?
examples/ping.rs (line 9)
4fn main() {
5    let client = rootle_github::client::GitHubClient::new();
6    println!("anonymous: {}", client.is_anonymous());
7
8    let t0 = std::time::Instant::now();
9    match client.search("ratatui") {
10        Ok(items) => println!("search ok in {:?}: {} items", t0.elapsed(), items.len()),
11        Err(e) => println!("search ERR in {:?}: {e}", t0.elapsed()),
12    }
13
14    let t1 = std::time::Instant::now();
15    match client.org_repos("ratatui") {
16        Ok(repos) => println!("org ok in {:?}: {} repos", t1.elapsed(), repos.len()),
17        Err(e) => println!("org ERR in {:?}: {e}", t1.elapsed()),
18    }
19}
Source

pub fn org_repos(&self, org: &str) -> ProviderResult<Vec<RepoInfo>>

Examples found in repository?
examples/ping.rs (line 15)
4fn main() {
5    let client = rootle_github::client::GitHubClient::new();
6    println!("anonymous: {}", client.is_anonymous());
7
8    let t0 = std::time::Instant::now();
9    match client.search("ratatui") {
10        Ok(items) => println!("search ok in {:?}: {} items", t0.elapsed(), items.len()),
11        Err(e) => println!("search ERR in {:?}: {e}", t0.elapsed()),
12    }
13
14    let t1 = std::time::Instant::now();
15    match client.org_repos("ratatui") {
16        Ok(repos) => println!("org ok in {:?}: {} repos", t1.elapsed(), repos.len()),
17        Err(e) => println!("org ERR in {:?}: {e}", t1.elapsed()),
18    }
19}
Source

pub fn search_code(&self, q: &str) -> ProviderResult<(Vec<CodeItem>, bool)>

Code search (plans/0002 §4). Requires auth — anonymous clients get a clear error. q is the full query string including qualifiers (repo:, org:, extension:, path:); text-match fragments are requested for previews.

Source

pub fn search_code_page( &self, q: &str, page: u32, ) -> ProviderResult<(Vec<CodeItem>, u64)>

One page of code search (per_page=100, 1-indexed pages). Returns (items, total_count) — total drives truncated and the progressive page loop (v1.3, plans/0011).

Source§

impl GitHubClient

Source

pub fn fetch_tree( &self, owner: &str, repo: &str, ref_: Option<&str>, ) -> ProviderResult<(TreeResponse, bool, String)>

Fetch a repo’s full recursive tree with the sha-keyed cache (PLAN.md §8): revalidate the branch ref with If-None-Match (304 = free, tree unchanged), cache tree bodies by their sha. Also returns the default branch (URL building, yank). v1.5: ref_ pins another branch/tag/sha — the tree endpoint takes any ref, and a sha’s tree is immutable, so the same etag revalidation is correct there.

Source§

impl GitHubClient

Source

pub fn new() -> Self

Examples found in repository?
examples/ping.rs (line 5)
4fn main() {
5    let client = rootle_github::client::GitHubClient::new();
6    println!("anonymous: {}", client.is_anonymous());
7
8    let t0 = std::time::Instant::now();
9    match client.search("ratatui") {
10        Ok(items) => println!("search ok in {:?}: {} items", t0.elapsed(), items.len()),
11        Err(e) => println!("search ERR in {:?}: {e}", t0.elapsed()),
12    }
13
14    let t1 = std::time::Instant::now();
15    match client.org_repos("ratatui") {
16        Ok(repos) => println!("org ok in {:?}: {} repos", t1.elapsed(), repos.len()),
17        Err(e) => println!("org ERR in {:?}: {e}", t1.elapsed()),
18    }
19}
Source

pub fn anonymous() -> Self

No environment or credential process; useful for anonymous browsing.

Source

pub fn is_anonymous(&self) -> bool

Examples found in repository?
examples/ping.rs (line 6)
4fn main() {
5    let client = rootle_github::client::GitHubClient::new();
6    println!("anonymous: {}", client.is_anonymous());
7
8    let t0 = std::time::Instant::now();
9    match client.search("ratatui") {
10        Ok(items) => println!("search ok in {:?}: {} items", t0.elapsed(), items.len()),
11        Err(e) => println!("search ERR in {:?}: {e}", t0.elapsed()),
12    }
13
14    let t1 = std::time::Instant::now();
15    match client.org_repos("ratatui") {
16        Ok(repos) => println!("org ok in {:?}: {} repos", t1.elapsed(), repos.len()),
17        Err(e) => println!("org ERR in {:?}: {e}", t1.elapsed()),
18    }
19}

Trait Implementations§

Source§

impl Default for GitHubClient

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

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

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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