pub struct ZLayerDirs { /* private fields */ }Expand description
Centralized filesystem path resolution for ZLayer.
All ZLayer crates should use this instead of hardcoding paths.
Implementations§
Source§impl ZLayerDirs
impl ZLayerDirs
Sourcepub fn system_default() -> Self
pub fn system_default() -> Self
Create using the platform default data directory.
Sourcepub fn default_data_dir() -> PathBuf
pub fn default_data_dir() -> PathBuf
Platform-aware default data directory.
- macOS:
~/.zlayer - Linux (root):
/var/lib/zlayer - Linux (user):
~/.zlayer - Windows:
%ProgramData%\ZLayer(system) orC:\ProgramData\ZLayerfallback. HCS-backed nodes run as SYSTEM so the system-wideProgramDatalocation is the right default.
Sourcepub fn detect_data_dir() -> PathBuf
pub fn detect_data_dir() -> PathBuf
Detect the data directory of an existing installation.
On Linux, if not root, checks whether /var/lib/zlayer/daemon.json
exists (indicating a system-level install) and returns
/var/lib/zlayer if so. On Windows, probes %ProgramData%\ZLayer
for a daemon.json marker in case the caller lacks the env var but
a prior system install is present. Otherwise falls back to
[default_data_dir].
Sourcepub fn default_run_dir() -> PathBuf
pub fn default_run_dir() -> PathBuf
Default runtime directory.
- Linux:
/var/run/zlayer - macOS:
{default_data_dir}/run - Windows:
{default_data_dir}\run(i.e.%ProgramData%\ZLayer\run)
Sourcepub fn default_run_dir_for(data_dir: &Path) -> PathBuf
pub fn default_run_dir_for(data_dir: &Path) -> PathBuf
Data-dir-aware default run directory.
Returns the platform’s system default (e.g. /var/run/zlayer on Linux)
when data_dir matches Self::default_data_dir; otherwise returns
{data_dir}/run. This preserves the FHS layout for stock installs while
letting --data-dir /tmp/foo get a fully isolated runtime directory.
Sourcepub fn default_log_dir() -> PathBuf
pub fn default_log_dir() -> PathBuf
Default log directory.
- Linux:
/var/log/zlayer - macOS:
{default_data_dir}/logs - Windows:
{default_data_dir}\logs(i.e.%ProgramData%\ZLayer\logs)
Sourcepub fn default_log_dir_for(data_dir: &Path) -> PathBuf
pub fn default_log_dir_for(data_dir: &Path) -> PathBuf
Data-dir-aware default log directory.
Returns the platform’s system default (e.g. /var/log/zlayer on Linux)
when data_dir matches Self::default_data_dir; otherwise returns
{data_dir}/logs. This preserves the FHS layout for stock installs
while letting --data-dir /tmp/foo get a fully isolated log directory.
Sourcepub fn default_socket_path() -> String
pub fn default_socket_path() -> String
Default Unix socket path.
- Linux:
/var/run/zlayer.sock - macOS:
{default_data_dir}/run/zlayer.sock - Windows:
tcp://127.0.0.1:3669
Sourcepub fn default_socket_path_for(data_dir: &Path) -> String
pub fn default_socket_path_for(data_dir: &Path) -> String
Data-dir-aware default daemon socket path.
On Windows always returns tcp://127.0.0.1:3669 regardless of
data_dir (the daemon listens on TCP loopback, not a filesystem
socket). On Unix, returns the platform’s system default when
data_dir matches Self::default_data_dir; otherwise returns
{data_dir}/run/zlayer.sock. Stock installs keep their FHS-style
path while --data-dir /tmp/foo gets an isolated socket.
Sourcepub fn default_docker_socket_path() -> String
pub fn default_docker_socket_path() -> String
Default Docker-compatible API socket path.
- Linux (root):
/var/run/zlayer/docker.sock - Linux (user,
XDG_RUNTIME_DIRset):{XDG_RUNTIME_DIR}/zlayer/docker.sock - Linux (user, no
XDG_RUNTIME_DIR):{default_data_dir}/run/docker.sock - macOS:
{default_data_dir}/run/docker.sock - Windows:
\\.\pipe\zlayer-docker
Sourcepub fn default_binary_dir() -> PathBuf
pub fn default_binary_dir() -> PathBuf
Preferred system directory for the zlayer binary.
Tries /usr/local/bin first (standard FHS, writable on most systems).
Falls back to {data_dir}/bin (/var/lib/zlayer/bin on Linux as root)
which is always writable since ZLayer owns that directory.
On macOS and Windows, returns /usr/local/bin or the data-dir bin
subdirectory respectively.
Sourcepub fn containers(&self) -> PathBuf
pub fn containers(&self) -> PathBuf
Container state directory ({data}/containers).
Sourcepub fn wasm_compiled(&self) -> PathBuf
pub fn wasm_compiled(&self) -> PathBuf
AOT-compiled WASM cache directory ({data}/wasm/compiled).
Sourcepub fn admin_password(&self) -> PathBuf
pub fn admin_password(&self) -> PathBuf
Admin password file path ({data}/admin_password).
Sourcepub fn admin_bearer_path(&self) -> PathBuf
pub fn admin_bearer_path(&self) -> PathBuf
Path to the persisted local-admin bearer token file.
On Linux/macOS this file is informational — the daemon’s UDS middleware
already injects the bearer into UDS-originated requests. On Windows the
DaemonClient reads this file on connect to authenticate against the
loopback TCP listener (which has no socket-path-based local-admin
bypass).
Default: <data_dir>/admin_bearer.token
On Windows this resolves under %ProgramData%\ZLayer so the file
inherits the parent ACL (SYSTEM + Administrators write, Users read),
which is adequate for the local-admin bearer.
Sourcepub fn daemon_json(&self) -> PathBuf
pub fn daemon_json(&self) -> PathBuf
Daemon metadata file path ({data}/daemon.json).
Sourcepub fn agent_ipam_state(&self) -> PathBuf
pub fn agent_ipam_state(&self) -> PathBuf
Path to the agent’s local IPAM (per-node slice allocator) state file.
Sourcepub fn logs(&self) -> PathBuf
pub fn logs(&self) -> PathBuf
Logs subdirectory under data_dir ({data}/logs).
Used on macOS where logs live under the user data dir.
Sourcepub fn toolchain_cache(&self) -> PathBuf
pub fn toolchain_cache(&self) -> PathBuf
Toolchain download cache directory ({data}/toolchain-cache).
Sourcepub fn wireguard(&self) -> PathBuf
pub fn wireguard(&self) -> PathBuf
Data-dir-aware WireGuard UAPI socket directory.
When data_dir == Self::default_data_dir(), returns
/var/run/wireguard (FHS default — also where wg(8) looks).
Otherwise returns {data_dir}/run/wireguard so an isolated
install (e.g. --data-dir /tmp/foo) does not collide with a
system install on the same host.
macOS / Windows: always returns {data_dir}/run/wireguard
since the FHS path doesn’t apply.