tradingview/client/
core.rs1use std::sync::Arc;
2
3pub trait DataClient {
4 fn new(auth_token: Option<&str>) -> Arc<Self>;
5}
6
7pub fn validate_response_status(response: &reqwest::Response) -> Result<(), crate::Error> {
10 let status = response.status();
11 if status == reqwest::StatusCode::TOO_MANY_REQUESTS {
12 return Err(crate::Error::RateLimited(ustr::Ustr::from(&format!(
13 "HTTP 429 Too Many Requests: {}",
14 response.url()
15 ))));
16 }
17 if !status.is_success() {
18 return Err(crate::Error::Request(ustr::Ustr::from(&format!(
19 "HTTP request failed with status {}: {}",
20 status,
21 response.url()
22 ))));
23 }
24 Ok(())
25}