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 42)
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 match CookieReader::read_cookies(&prof, "github.com") {
14 Ok(cookies) => {
15 let has_user_session = cookies.iter().any(|c| {
16 c.name == "user_session" || c.name == "__Host-user_session_same_site"
17 });
18
19 if !has_user_session {
20 continue;
21 }
22
23 let dotcom_user = cookies
24 .iter()
25 .find(|c| c.name == "dotcom_user")
26 .map(|c| c.value.as_str())
27 .unwrap_or("unknown");
28 println!(
29 "Using {} - {} ({} cookies, user={})",
30 browser.name(),
31 prof.name,
32 cookies.len(),
33 dotcom_user
34 );
35
36 match seher::copilot::CopilotClient::fetch_quota(&cookies).await {
37 Ok(quota) => {
38 println!("\nSuccess! Copilot quota:");
39 println!(" chat_utilization: {:.1}%", quota.chat_utilization);
40 println!(" premium_utilization: {:.1}%", quota.premium_utilization);
41 println!(" reset_time: {:?}", quota.reset_time);
42 println!(" is_limited: {}", quota.is_limited());
43 return;
44 }
45 Err(e) => {
46 println!("\nFailed to fetch Copilot quota: {}", e);
47 }
48 }
49 }
50 Err(_) => {}
51 }
52 }
53 }
54
55 println!("No github.com session with user_session cookie found");
56}pub fn next_reset_time(&self) -> Option<DateTime<Utc>>
Trait Implementations§
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