Skip to main content

Suite

Struct Suite 

Source
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

Source

pub fn app_root(&self, app: &str) -> Result<AppRoot, AppRootError>

The per-app root for app, created private. See AppRoot.

Source§

impl Suite

Source

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.

Source

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> from getpwuid_r(geteuid()).
  • Linux: <home>/.local/share/Orthic Labs/shared. XDG_DATA_HOME is 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> from SHGetKnownFolderPath(FOLDERID_LocalAppData), which reads the profile’s registry, not %LOCALAPPDATA%.
  • Other Unix: not implemented; fails closed.
Source

pub 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

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.

Source

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.

Source

pub fn at(root: impl Into<PathBuf>) -> Result<Suite, SuiteError>

An explicit absolute root (isolated dev profiles, tests).

Source

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.

Source

pub fn root(&self) -> &Path

Source

pub fn service_dir(&self, service: &str) -> PathBuf

<suite>/runtime/<service>.

Source

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.

Source

pub fn data_dir(&self, area: &str) -> Result<PathBuf, SuiteError>

<suite>/<area>: shared app data that must not be relative to the cwd (screenshots, evidence, models). Created private to the user.

Trait Implementations§

Source§

impl Clone for Suite

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Suite

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Suite

§

impl RefUnwindSafe for Suite

§

impl Send for Suite

§

impl Sync for Suite

§

impl Unpin for Suite

§

impl UnsafeUnpin for Suite

§

impl UnwindSafe for Suite

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.