pub struct Suite { /* private fields */ }Expand description
The per-user suite directory that holds runtime/<service>/service.json
and other shared state. Always absolute.
Implementations§
Source§impl Suite
impl Suite
Sourcepub fn resolve() -> Result<Suite, SuiteError>
pub fn resolve() -> Result<Suite, SuiteError>
RIGHTKIT_SUITE_ROOT if set, else the platform per-user default
(~/Library/Application Support/Orthic Labs/shared, %LOCALAPPDATA%\Orthic Labs\shared).
Errors, never guesses, when the environment does not name an absolute root.
Everything here comes from the environment, which is chosen by whoever launches the
process: RIGHTKIT_SUITE_ROOT, RIGHT_SUITE_DIR and ORTHIC_SHARED_DIR redirect the root
anywhere, and HOME (macOS, Linux), XDG_DATA_HOME (Linux) and LOCALAPPDATA (Windows)
redirect the default. That is right for tests and isolated dev profiles and wrong for a
release build that talks to its installed app: use Suite::per_user_default or
Suite::resolve_ignoring_env_overrides there. The returned suite reports
Suite::env_derived true.
Release builds (without the test-mode feature) read no override switch at all: this
returns Suite::per_user_default (account database / known-folder table), reports
Suite::env_derived false because nothing came from the environment, and the binary
contains no code that reads the variables above. The environment paragraph applies only
to a build that compiles test-mode.
Sourcepub fn per_user_default() -> Result<Suite, SuiteError>
pub fn per_user_default() -> Result<Suite, SuiteError>
The per-user default suite root from the operating system’s account database, never from
the environment: no RIGHTKIT_SUITE_ROOT/RIGHT_SUITE_DIR/ORTHIC_SHARED_DIR, no HOME,
no XDG_DATA_HOME, no LOCALAPPDATA. This is what a release build of an app or of its
command-line engine should use, on the host side as well as the client side, so that a
launcher cannot point either at a different directory.
- macOS:
<home>/Library/Application Support/Orthic Labs/shared,<home>fromgetpwuid_r(geteuid()). - Linux:
<home>/.local/share/Orthic Labs/shared.XDG_DATA_HOMEis an environment variable and is ignored, so a user who relocated it must host with this function too, or host and hardened client disagree on the root. - Windows:
<local app data>\Orthic Labs\shared,<local app data>fromSHGetKnownFolderPath(FOLDERID_LocalAppData), which reads the profile’s registry, not%LOCALAPPDATA%. - Other Unix: not implemented; fails closed.
Sourcepub fn resolve_ignoring_env_overrides(
ignore_env_overrides: bool,
) -> Result<Suite, SuiteError>
👎Deprecated since 0.1.6: use rightkit_daemon::mode::{decide, roots}: release builds read no override selector, test builds fail closed on a validated TestRoot
pub fn resolve_ignoring_env_overrides( ignore_env_overrides: bool, ) -> Result<Suite, SuiteError>
use rightkit_daemon::mode::{decide, roots}: release builds read no override selector, test builds fail closed on a validated TestRoot
One switch for hosts and clients: with ignore_env_overrides the root is
Suite::per_user_default, otherwise Suite::resolve. A release build passes true,
a QA build false; wire the flag to a cargo feature or cfg!(debug_assertions) in the
app, not to the environment.
Deprecated. This is one boolean the caller must remember to pass; nothing checks that it
did, and a build that passes false still contains the code that reads the override
variables. crate::mode::roots with a crate::mode::Mode from crate::mode::decide
replaces it: a release build (without the test-mode feature) reads no override selector at
all, and a test-capable build fails closed on a validated test root. Kept, unchanged, for
existing HeardRight and CodeRight callers.
Without the test-mode feature the flag is ignored: this is an alias of
Suite::per_user_default and reads no environment.
Sourcepub fn env_derived(&self) -> bool
pub fn env_derived(&self) -> bool
Whether the root was derived from the environment (Suite::resolve). A suite from
Suite::at, Suite::per_user_default or Suite::per_run_temp is not.
Sourcepub fn at(root: impl Into<PathBuf>) -> Result<Suite, SuiteError>
pub fn at(root: impl Into<PathBuf>) -> Result<Suite, SuiteError>
An explicit absolute root (isolated dev profiles, tests).
Sourcepub fn per_run_temp(label: &str) -> Result<Suite, SuiteError>
pub fn per_run_temp(label: &str) -> Result<Suite, SuiteError>
A fresh private directory under the OS temp dir, deleted when the last clone is dropped. The explicit alternative to a missing app-data root.
pub fn root(&self) -> &Path
Sourcepub fn service_dir(&self, service: &str) -> PathBuf
pub fn service_dir(&self, service: &str) -> PathBuf
<suite>/runtime/<service>.
Sourcepub fn private_service_subdir(
&self,
service: &str,
name: &str,
) -> Result<PathBuf, SuiteError>
pub fn private_service_subdir( &self, service: &str, name: &str, ) -> Result<PathBuf, SuiteError>
A private (owner-only) directory under <suite>/runtime/<service>, e.g. shots.