From 2f671f196e245ac1a791c001286e401a2fab9d3a Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Mon, 20 Jul 2026 23:00:06 +0200 Subject: chore: Commit --- crates/common/src/utils.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'crates/common/src/utils.rs') diff --git a/crates/common/src/utils.rs b/crates/common/src/utils.rs index d6077ee7..4451140b 100644 --- a/crates/common/src/utils.rs +++ b/crates/common/src/utils.rs @@ -4,6 +4,24 @@ use std::path::{Path, PathBuf}; use uuid::Uuid; +#[must_use] +pub fn get_hostname() -> String { + env::var("ATUIN_HOST_NAME") + .unwrap_or_else(|_| whoami::hostname().unwrap_or_else(|_| "unknown-host".to_string())) +} + +#[must_use] +pub fn get_username() -> String { + env::var("ATUIN_HOST_USER") + .unwrap_or_else(|_| whoami::username().unwrap_or_else(|_| "unknown-user".to_string())) +} + +/// Returns a pair of the hostname and username, separated by a colon. +#[must_use] +pub fn get_host_user() -> String { + format!("{}:{}", get_hostname(), get_username()) +} + pub fn uuid_v7() -> Uuid { Uuid::now_v7() } -- cgit v1.3.1