#[must_use]
pub const fn os_name() -> &'static str {
#[cfg(target_os = "linux")]
{
"linux"
}
#[cfg(target_os = "macos")]
{
"darwin"
}
#[cfg(target_os = "windows")]
{
"windows"
}
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
{
"unknown"
}
}
#[must_use]
pub const fn arch_name() -> &'static str {
#[cfg(target_arch = "x86_64")]
{
"x86_64"
}
#[cfg(target_arch = "aarch64")]
{
"aarch64"
}
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
{
"unknown"
}
}
#[must_use]
pub const fn exe_suffix() -> &'static str {
if cfg!(target_os = "windows") {
".exe"
} else {
""
}
}
#[must_use]
pub fn download_name() -> String {
format!(
"plushie-renderer-{}-{}{}",
os_name(),
arch_name(),
exe_suffix()
)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn download_name_well_formed() {
let name = download_name();
assert!(name.starts_with("plushie-renderer-"));
}
}