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
41 .code_review_rate_limit
42 .as_ref()
43 .is_some_and(seher::CodexRateLimit::is_limited)
44 );
45 return;
46 }
47 Err(e) => {
48 println!("\nFailed to fetch Codex usage: {e}");
49 }
50 }
51 }
52 }
53 }
54
55 println!("No chatgpt.com session with __Secure-next-auth.session-token found");
56}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
41 .code_review_rate_limit
42 .as_ref()
43 .is_some_and(seher::CodexRateLimit::is_limited)
44 );
45 return;
46 }
47 Err(e) => {
48 println!("\nFailed to fetch Codex usage: {e}");
49 }
50 }
51 }
52 }
53 }
54
55 println!("No chatgpt.com session with __Secure-next-auth.session-token found");
56}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 (const: unstable) · 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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> ModelDump for Twhere
T: Serialize,
impl<T> ModelDump for Twhere
T: Serialize,
Source§fn model_dump(&self, options: DumpOptions) -> Result<Value, Error>
fn model_dump(&self, options: DumpOptions) -> Result<Value, Error>
Serialize a model to a JSON value. Read more
Source§fn model_dump_json(&self) -> Result<String, Error>
fn model_dump_json(&self) -> Result<String, Error>
Serialize a model to a JSON string with default options.
Source§fn model_dump_json_pretty(&self) -> Result<String, Error>
fn model_dump_json_pretty(&self) -> Result<String, Error>
Serialize a model to a pretty-printed JSON string.
Source§fn model_dump_json_with_options(
&self,
options: DumpOptions,
) -> Result<String, Error>
fn model_dump_json_with_options( &self, options: DumpOptions, ) -> Result<String, Error>
Serialize a model to a JSON string with full options support. Read more
Source§impl<T> ModelValidate for Twhere
T: DeserializeOwned,
impl<T> ModelValidate for Twhere
T: DeserializeOwned,
Source§fn model_validate(
input: impl Into<ValidateInput>,
options: ValidateOptions,
) -> Result<T, ValidationError>
fn model_validate( input: impl Into<ValidateInput>, options: ValidateOptions, ) -> Result<T, ValidationError>
Create and validate a model from input. Read more
Source§fn model_validate_json(json: &str) -> Result<Self, ValidationError>
fn model_validate_json(json: &str) -> Result<Self, ValidationError>
Create and validate a model from JSON string with default options.
Source§fn model_validate_dict(
dict: HashMap<String, Value>,
) -> Result<Self, ValidationError>
fn model_validate_dict( dict: HashMap<String, Value>, ) -> Result<Self, ValidationError>
Create and validate a model from a HashMap with default options.