acorn_lib/
prelude.rs

1//! Wrapper module isolate `std` usage and enable `no_std` support
2
3/// Module that provides `std` support
4#[allow(unused_imports)]
5mod std {
6    pub use std::collections::HashMap;
7    pub use std::env::{consts, var};
8    pub use std::ffi::OsStr;
9    pub use std::fs::{canonicalize, create_dir_all, read, remove_file, set_permissions, File, Permissions};
10    pub use std::io::prelude::*;
11    pub use std::io::{self, copy, BufRead, BufReader, Cursor, Write};
12    pub use std::os::unix::fs::PermissionsExt;
13    pub use std::path::{absolute, Path, PathBuf};
14    pub use std::process::exit;
15}
16/// Module that provides `no-std` support
17#[allow(unused_imports)]
18mod no_std {
19    pub use hashbrown::HashMap;
20}
21
22#[cfg(not(feature = "std"))]
23pub use no_std::*;
24#[cfg(feature = "std")]
25pub use std::*;
26/// Get Vale release filename for a given platform operating system (e.g., linux, windows, macos)
27#[cfg(feature = "std")]
28pub fn vale_release_filename() -> String {
29    // https://doc.rust-lang.org/std/env/consts/constant.OS.html
30    let os = std::consts::OS.to_lowercase();
31    let platform = match os.as_str() {
32        | "linux" => "Linux_64-bit.tar.gz",
33        | "macos" | "apple" => "macOS_64-bit.tar.gz",
34        | "windows" => "Windows_64-bit.zip",
35        | _ => "unknown",
36    };
37    platform.to_string()
38}