pub struct CopilotClient;Implementations§
Source§impl CopilotClient
impl CopilotClient
Sourcepub async fn fetch_quota_with_header(
cookie_header: &str,
) -> Result<CopilotQuota, Box<dyn Error>>
pub async fn fetch_quota_with_header( cookie_header: &str, ) -> Result<CopilotQuota, Box<dyn Error>>
Fetch quota using a pre-built cookie header string.
§Errors
Returns an error if the GitHub Copilot API request fails or the response cannot be parsed.
Sourcepub async fn fetch_quota(
cookies: &[Cookie],
) -> Result<CopilotQuota, Box<dyn Error>>
pub async fn fetch_quota( cookies: &[Cookie], ) -> Result<CopilotQuota, Box<dyn Error>>
§Errors
Returns an error if the GitHub Copilot API request fails or the response cannot be parsed.
Examples found in repository?
examples/test_copilot.rs (line 34)
4async fn main() {
5 let detector = BrowserDetector::new();
6 let browsers = detector.detect_browsers();
7
8 for browser in &browsers {
9 if !browser.is_chromium_based() {
10 continue;
11 }
12 for prof in detector.list_profiles(*browser) {
13 if let Ok(cookies) = CookieReader::read_cookies(&prof, "github.com") {
14 let has_user_session = cookies
15 .iter()
16 .any(|c| c.name == "user_session" || c.name == "__Host-user_session_same_site");
17
18 if !has_user_session {
19 continue;
20 }
21
22 let dotcom_user = cookies
23 .iter()
24 .find(|c| c.name == "dotcom_user")
25 .map_or("unknown", |c| c.value.as_str());
26 println!(
27 "Using {} - {} ({} cookies, user={})",
28 browser.name(),
29 prof.name,
30 cookies.len(),
31 dotcom_user
32 );
33
34 match seher::copilot::CopilotClient::fetch_quota(&cookies).await {
35 Ok(quota) => {
36 println!("\nSuccess! Copilot quota:");
37 println!(" chat_utilization: {:.1}%", quota.chat_utilization);
38 println!(" premium_utilization: {:.1}%", quota.premium_utilization);
39 println!(" reset_time: {:?}", quota.reset_time);
40 println!(" is_limited: {}", quota.is_limited());
41 return;
42 }
43 Err(e) => {
44 println!("\nFailed to fetch Copilot quota: {e}");
45 }
46 }
47 }
48 }
49 }
50
51 println!("No github.com session with user_session cookie found");
52}Auto Trait Implementations§
impl Freeze for CopilotClient
impl RefUnwindSafe for CopilotClient
impl Send for CopilotClient
impl Sync for CopilotClient
impl Unpin for CopilotClient
impl UnsafeUnpin for CopilotClient
impl UnwindSafe for CopilotClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more