pub struct GitHubClient { /* private fields */ }Implementations§
Source§impl GitHubClient
impl GitHubClient
Sourcepub fn blame(
&self,
owner: &str,
repo: &str,
path: &str,
ref_: Option<&str>,
) -> ProviderResult<Vec<BlameRange>>
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
impl GitHubClient
Sourcepub fn blob_at(
&self,
owner: &str,
repo: &str,
path: &str,
ref_: Option<&str>,
) -> ProviderResult<(Vec<u8>, String)>
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).
Sourcepub fn source_tarball(&self, repo: &str) -> ProviderResult<Vec<u8>>
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.
Sourcepub fn fetch_blob(
&self,
owner: &str,
repo: &str,
sha: &str,
) -> ProviderResult<Vec<u8>>
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
impl GitHubClient
Sourcepub fn log(
&self,
owner: &str,
repo: &str,
path: Option<&str>,
ref_: Option<&str>,
limit: Option<usize>,
) -> ProviderResult<(Vec<LogEntry>, bool)>
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).
Sourcepub fn commit(
&self,
owner: &str,
repo: &str,
sha: &str,
) -> ProviderResult<CommitResponse>
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
impl GitHubClient
Source§impl GitHubClient
impl GitHubClient
Sourcepub fn search(&self, query: &str) -> ProviderResult<Vec<SearchItem>>
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?
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}Sourcepub fn org_repos(&self, org: &str) -> ProviderResult<Vec<RepoInfo>>
pub fn org_repos(&self, org: &str) -> ProviderResult<Vec<RepoInfo>>
Examples found in repository?
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}Sourcepub fn search_code(&self, q: &str) -> ProviderResult<(Vec<CodeItem>, bool)>
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.
Sourcepub fn search_code_page(
&self,
q: &str,
page: u32,
) -> ProviderResult<(Vec<CodeItem>, u64)>
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
impl GitHubClient
Sourcepub fn fetch_tree(
&self,
owner: &str,
repo: &str,
ref_: Option<&str>,
) -> ProviderResult<(TreeResponse, bool, String)>
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
impl GitHubClient
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
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}Sourcepub fn anonymous() -> Self
pub fn anonymous() -> Self
No environment or credential process; useful for anonymous browsing.
Sourcepub fn is_anonymous(&self) -> bool
pub fn is_anonymous(&self) -> bool
Examples found in repository?
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}