Skip to main content

HomeDirsExt

Trait HomeDirsExt 

Source
pub trait HomeDirsExt: Sized {
    // Required method
    fn sysdir() -> Result<Self>;
}
ⓘ This trait cannot be implemented outside std.
🔬This is a nightly-only experimental API. (fs_home_dirs #162082)
Available on Apple only.
Expand description

Darwin-specific extensions to fs::HomeDirs.

Required Methods§

Source

fn sysdir() -> Result<Self>

🔬This is a nightly-only experimental API. (fs_home_dirs #162082)

Load the standard user directory paths for the current user.

On iOS, tvOS, watchOS, visionOS, and sandboxed macOS applications, these directories are within the application’s container. Outside the sandbox, these are subdirectories of the ~/Library directory on macOS.

The produced directory paths are not guaranteed to be the canonical paths to the directories; they are allowed to be sandbox-redirected paths as long as the directory is accessible there.

The loaded common directories are:

HomeDirsNSSearchPathDirectory
cache_homeNSCachesDirectory (~/Library/Caches)
config_homeNSApplicationSupportDirectory (~/Library/Application Support)
data_homeNSApplicationSupportDirectory (~/Library/Application Support)
state_homeNSApplicationSupportDirectory (~/Library/Application Support)

Note that the Application Support directory is used for the config, data, and state directories. It is always possible for multiple user directories to be configured to the same path, but this is the common configuration on Apple platforms, making it even more important to not assume files in different user directories cannot alias each other.

§Errors

Errors if the user home cannot be determined.

§Implementation-specific behavior

Uses the sysdir(3) API from libSystem to discover the standard user directories.

This behavior may change in the future. One example change that we explicitly reserve the right to make is to load additional common directories not currently in this list.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§