diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/structures.rs | 10 | ||||
| -rw-r--r-- | src/utils.rs | 6 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/structures.rs b/src/structures.rs index 13f904d..0e9f227 100644 --- a/src/structures.rs +++ b/src/structures.rs @@ -10,6 +10,16 @@ pub struct GitHubAPIResponse { pub tree: Vec<GitHubAPIResponseTree>, pub truncated: bool, } +impl Default for GitHubAPIResponse { + fn default() -> Self { + GitHubAPIResponse { + sha: "rate limited".to_string(), + url: "rate limited".to_string(), + tree: vec![], + truncated: false, + } + } +} #[derive(Serialize, Deserialize, Debug)] pub struct GitHubAPIResponseTree { diff --git a/src/utils.rs b/src/utils.rs index bf10d71..b4672e0 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -18,9 +18,9 @@ pub async fn github_api() -> Result<GitHubAPIResponse, Box<dyn std::error::Error std::env::var("GITHUB_TOKEN").unwrap_or_else(|_| "Null".to_string()) ), ) + .timeout(std::time::Duration::from_secs(60)) .send() - .await - .unwrap() + .await? .json::<GitHubAPIResponse>() .limit(20_000_000) .await @@ -31,7 +31,7 @@ pub async fn github_api() -> Result<GitHubAPIResponse, Box<dyn std::error::Error pub async fn filter_languages() -> Vec<String> { let mut languages = vec![]; - for i in github_api().await.unwrap().tree { + for i in github_api().await.unwrap_or_default().tree { if i._type == "tree" { languages.push(i.path); } |