We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8d6d7bb commit b582500Copy full SHA for b582500
1 file changed
src/utils.rs
@@ -1,5 +1,6 @@
1
use reqwest::header::{HeaderMap, ACCEPT, USER_AGENT};
2
use serde_json::Value;
3
+use std::path::{Path, PathBuf};
4
5
pub fn request(url: String) -> Result<Value, Box<dyn std::error::Error>> {
6
let headers = construct_header();
@@ -23,3 +24,15 @@ pub fn pretty_dates(date: &str) -> String {
23
24
let date = date[0].split('-').collect::<Vec<&str>>();
25
format!("{}-{}-{}", date[2], date[1], date[0])
26
}
27
+
28
+pub fn validate_path(path: String) -> Result<PathBuf, String> {
29
+ let real_path = Path::new(&path);
30
31
+ if !real_path.exists() {
32
+ return Err(format!("Failed to find path \"{}\"", path));
33
+ }
34
35
36
37
+ Ok(real_path.to_owned())
38
+}
0 commit comments