pub struct CodexRateLimit {
pub allowed: bool,
pub limit_reached: bool,
pub primary_window: Option<CodexWindow>,
pub secondary_window: Option<CodexWindow>,
}Fields§
§allowed: bool§limit_reached: bool§primary_window: Option<CodexWindow>§secondary_window: Option<CodexWindow>Implementations§
Source§impl CodexRateLimit
impl CodexRateLimit
Sourcepub fn is_limited(&self) -> bool
pub fn is_limited(&self) -> bool
Examples found in repository?
examples/test_codex.rs (line 33)
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, "chatgpt.com") {
14 let has_session = cookies
15 .iter()
16 .any(|c| c.name.starts_with("__Secure-next-auth.session-token"));
17
18 if !has_session {
19 continue;
20 }
21
22 println!(
23 "Using {} - {} ({} cookies)",
24 browser.name(),
25 prof.name,
26 cookies.len(),
27 );
28
29 match seher::codex::CodexClient::fetch_usage(&cookies).await {
30 Ok(usage) => {
31 println!("\nSuccess! Codex usage:");
32 println!(" plan_type: {}", usage.plan_type);
33 println!(" rate_limit limited: {}", usage.rate_limit.is_limited());
34 println!(
35 " rate_limit reset_time: {:?}",
36 usage.rate_limit.next_reset_time()
37 );
38 println!(
39 " code_review limited: {}",
40 usage.code_review_rate_limit.is_limited()
41 );
42 return;
43 }
44 Err(e) => {
45 println!("\nFailed to fetch Codex usage: {e}");
46 }
47 }
48 }
49 }
50 }
51
52 println!("No chatgpt.com session with __Secure-next-auth.session-token found");
53}Sourcepub fn next_reset_time(&self) -> Option<DateTime<Utc>>
pub fn next_reset_time(&self) -> Option<DateTime<Utc>>
Examples found in repository?
examples/test_codex.rs (line 36)
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, "chatgpt.com") {
14 let has_session = cookies
15 .iter()
16 .any(|c| c.name.starts_with("__Secure-next-auth.session-token"));
17
18 if !has_session {
19 continue;
20 }
21
22 println!(
23 "Using {} - {} ({} cookies)",
24 browser.name(),
25 prof.name,
26 cookies.len(),
27 );
28
29 match seher::codex::CodexClient::fetch_usage(&cookies).await {
30 Ok(usage) => {
31 println!("\nSuccess! Codex usage:");
32 println!(" plan_type: {}", usage.plan_type);
33 println!(" rate_limit limited: {}", usage.rate_limit.is_limited());
34 println!(
35 " rate_limit reset_time: {:?}",
36 usage.rate_limit.next_reset_time()
37 );
38 println!(
39 " code_review limited: {}",
40 usage.code_review_rate_limit.is_limited()
41 );
42 return;
43 }
44 Err(e) => {
45 println!("\nFailed to fetch Codex usage: {e}");
46 }
47 }
48 }
49 }
50 }
51
52 println!("No chatgpt.com session with __Secure-next-auth.session-token found");
53}Trait Implementations§
Source§impl Clone for CodexRateLimit
impl Clone for CodexRateLimit
Source§fn clone(&self) -> CodexRateLimit
fn clone(&self) -> CodexRateLimit
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CodexRateLimit
impl Debug for CodexRateLimit
Source§impl<'de> Deserialize<'de> for CodexRateLimit
impl<'de> Deserialize<'de> for CodexRateLimit
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CodexRateLimit
impl RefUnwindSafe for CodexRateLimit
impl Send for CodexRateLimit
impl Sync for CodexRateLimit
impl Unpin for CodexRateLimit
impl UnsafeUnpin for CodexRateLimit
impl UnwindSafe for CodexRateLimit
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