pub struct CookieReader;Implementations§
Source§impl CookieReader
impl CookieReader
Examples found in repository?
examples/test_copilot.rs (line 13)
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}Auto Trait Implementations§
impl Freeze for CookieReader
impl RefUnwindSafe for CookieReader
impl Send for CookieReader
impl Sync for CookieReader
impl Unpin for CookieReader
impl UnsafeUnpin for CookieReader
impl UnwindSafe for CookieReader
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