pub struct CopilotQuota {
pub chat_utilization: f64,
pub premium_utilization: f64,
pub reset_time: Option<DateTime<Utc>>,
}Fields§
§chat_utilization: f64§reset_time: Option<DateTime<Utc>>Implementations§
Source§impl CopilotQuota
impl CopilotQuota
Sourcepub fn is_limited(&self) -> bool
pub fn is_limited(&self) -> bool
Examples found in repository?
examples/test_copilot.rs (line 41)
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(|c| c.value.as_str())
26 .unwrap_or("unknown");
27 println!(
28 "Using {} - {} ({} cookies, user={})",
29 browser.name(),
30 prof.name,
31 cookies.len(),
32 dotcom_user
33 );
34
35 match seher::copilot::CopilotClient::fetch_quota(&cookies).await {
36 Ok(quota) => {
37 println!("\nSuccess! Copilot quota:");
38 println!(" chat_utilization: {:.1}%", quota.chat_utilization);
39 println!(" premium_utilization: {:.1}%", quota.premium_utilization);
40 println!(" reset_time: {:?}", quota.reset_time);
41 println!(" is_limited: {}", quota.is_limited());
42 return;
43 }
44 Err(e) => {
45 println!("\nFailed to fetch Copilot quota: {}", e);
46 }
47 }
48 }
49 }
50 }
51
52 println!("No github.com session with user_session cookie found");
53}pub fn next_reset_time(&self) -> Option<DateTime<Utc>>
Trait Implementations§
Source§impl Debug for CopilotQuota
impl Debug for CopilotQuota
Auto Trait Implementations§
impl Freeze for CopilotQuota
impl RefUnwindSafe for CopilotQuota
impl Send for CopilotQuota
impl Sync for CopilotQuota
impl Unpin for CopilotQuota
impl UnsafeUnpin for CopilotQuota
impl UnwindSafe for CopilotQuota
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