chromedriver_update/
constant.rs1use std::sync::LazyLock;
2
3pub static CHROME_DRIVER_PATH: LazyLock<String> = LazyLock::new(|| {
9 let prefix = match std::env::consts::OS {
10 "macos" => "/usr/local/bin",
11 "linux" => "/usr/bin",
12 "windows" => "",
13 _ => "",
14 };
15
16 if !prefix.eq("") {
17 format!("{}/{}", prefix, DRIVERNAME).to_string()
18 } else {
19 "".to_string()
20 }
21});
22
23pub static CHROME_BROWSER_PATH: LazyLock<String> = LazyLock::new(|| {
29 match std::env::consts::OS {
30 "macos" => "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
31 "linux" => "/usr/bin/google-chrome",
32 "windows" => "",
33 _ => "",
34 }
35 .to_string()
36});
37
38pub static CONNECT_TIMEOUT: u64 = 5000;
40
41pub static TIMEOUT: u64 = 10000;
43
44static OS: LazyLock<String> = LazyLock::new(|| {
45 match (std::env::consts::OS, std::env::consts::ARCH) {
46 ("macos", "x86_64") => "mac-x64",
47 ("macos", "aarch64") => "mac-arm64",
48 ("windows", "x86") => "win32",
49 ("windows", "x86_64") => "win64",
50 ("linux", "x86_64") => "linux64",
51 _ => "",
52 }
53 .to_string()
54});
55
56static DRIVERNAME: &str = "chromedriver";
57
58static FILENAME: LazyLock<String> = LazyLock::new(|| format!("{}-{}", DRIVERNAME, OS.as_str()));
60
61pub static DRIVER_FILE: LazyLock<String> = LazyLock::new(|| {
65 #[cfg(unix)]
66 {
67 return format!("{}/{}", FILENAME.as_str(), DRIVERNAME);
68 }
69
70 #[cfg(windows)]
71 {
72 return format!("{}/{}.exe", FILENAME.as_str(), DRIVERNAME);
73 }
74});
75
76pub static ZIP_PATH: LazyLock<String> =
79 LazyLock::new(|| format!("{}/{}.zip", OS.as_str(), FILENAME.as_str()));