Struct tauri::path::PathResolver

source ·
pub struct PathResolver<R: Runtime>(/* private fields */);
Expand description

The path resolver is a helper class for general and application-specific path APIs.

Implementations§

source§

impl<R: Runtime> PathResolver<R>

source

pub fn audio_dir(&self) -> Result<PathBuf>

Returns the path to the user’s audio directory.

§Platform-specific
  • Linux: Resolves to xdg-user-dirsXDG_MUSIC_DIR.
  • macOS: Resolves to $HOME/Music.
  • Windows: Resolves to {FOLDERID_Music}.
source

pub fn cache_dir(&self) -> Result<PathBuf>

Returns the path to the user’s cache directory.

§Platform-specific
  • Linux: Resolves to $XDG_CACHE_HOME or $HOME/.cache.
  • macOS: Resolves to $HOME/Library/Caches.
  • Windows: Resolves to {FOLDERID_LocalAppData}.
source

pub fn config_dir(&self) -> Result<PathBuf>

Returns the path to the user’s config directory.

§Platform-specific
  • Linux: Resolves to $XDG_CONFIG_HOME or $HOME/.config.
  • macOS: Resolves to $HOME/Library/Application Support.
  • Windows: Resolves to {FOLDERID_RoamingAppData}.
source

pub fn data_dir(&self) -> Result<PathBuf>

Returns the path to the user’s data directory.

§Platform-specific
  • Linux: Resolves to $XDG_DATA_HOME or $HOME/.local/share.
  • macOS: Resolves to $HOME/Library/Application Support.
  • Windows: Resolves to {FOLDERID_RoamingAppData}.
source

pub fn local_data_dir(&self) -> Result<PathBuf>

Returns the path to the user’s local data directory.

§Platform-specific
  • Linux: Resolves to $XDG_DATA_HOME or $HOME/.local/share.
  • macOS: Resolves to $HOME/Library/Application Support.
  • Windows: Resolves to {FOLDERID_LocalAppData}.
source

pub fn desktop_dir(&self) -> Result<PathBuf>

Returns the path to the user’s desktop directory.

§Platform-specific
  • Linux: Resolves to xdg-user-dirsXDG_DESKTOP_DIR.
  • macOS: Resolves to $HOME/Desktop.
  • Windows: Resolves to {FOLDERID_Desktop}.
source

pub fn document_dir(&self) -> Result<PathBuf>

Returns the path to the user’s document directory.

§Platform-specific
  • Linux: Resolves to xdg-user-dirsXDG_DOCUMENTS_DIR.
  • macOS: Resolves to $HOME/Documents.
  • Windows: Resolves to {FOLDERID_Documents}.
source

pub fn download_dir(&self) -> Result<PathBuf>

Returns the path to the user’s download directory.

§Platform-specific
  • Linux: Resolves to xdg-user-dirsXDG_DOWNLOAD_DIR.
  • macOS: Resolves to $HOME/Downloads.
  • Windows: Resolves to {FOLDERID_Downloads}.
source

pub fn executable_dir(&self) -> Result<PathBuf>

Returns the path to the user’s executable directory.

§Platform-specific
  • Linux: Resolves to $XDG_BIN_HOME/../bin or $XDG_DATA_HOME/../bin or $HOME/.local/bin.
  • macOS: Not supported.
  • Windows: Not supported.
source

pub fn font_dir(&self) -> Result<PathBuf>

Returns the path to the user’s font directory.

§Platform-specific
  • Linux: Resolves to $XDG_DATA_HOME/fonts or $HOME/.local/share/fonts.
  • macOS: Resolves to $HOME/Library/Fonts.
  • Windows: Not supported.
source

pub fn home_dir(&self) -> Result<PathBuf>

Returns the path to the user’s home directory.

§Platform-specific
  • Linux: Resolves to $HOME.
  • macOS: Resolves to $HOME.
  • Windows: Resolves to {FOLDERID_Profile}.
source

pub fn picture_dir(&self) -> Result<PathBuf>

Returns the path to the user’s picture directory.

§Platform-specific
  • Linux: Resolves to xdg-user-dirsXDG_PICTURES_DIR.
  • macOS: Resolves to $HOME/Pictures.
  • Windows: Resolves to {FOLDERID_Pictures}.
source

pub fn public_dir(&self) -> Result<PathBuf>

Returns the path to the user’s public directory.

§Platform-specific
  • Linux: Resolves to xdg-user-dirsXDG_PUBLICSHARE_DIR.
  • macOS: Resolves to $HOME/Public.
  • Windows: Resolves to {FOLDERID_Public}.
source

pub fn runtime_dir(&self) -> Result<PathBuf>

Returns the path to the user’s runtime directory.

§Platform-specific
  • Linux: Resolves to $XDG_RUNTIME_DIR.
  • macOS: Not supported.
  • Windows: Not supported.
source

pub fn template_dir(&self) -> Result<PathBuf>

Returns the path to the user’s template directory.

§Platform-specific
  • Linux: Resolves to xdg-user-dirsXDG_TEMPLATES_DIR.
  • macOS: Not supported.
  • Windows: Resolves to {FOLDERID_Templates}.
source

pub fn video_dir(&self) -> Result<PathBuf>

Returns the path to the user’s video dir

§Platform-specific
  • Linux: Resolves to xdg-user-dirsXDG_VIDEOS_DIR.
  • macOS: Resolves to $HOME/Movies.
  • Windows: Resolves to {FOLDERID_Videos}.
source

pub fn resource_dir(&self) -> Result<PathBuf>

Returns the path to the resource directory of this app.

source

pub fn app_config_dir(&self) -> Result<PathBuf>

Returns the path to the suggested directory for your app’s config files.

Resolves to config_dir/${bundle_identifier}.

source

pub fn app_data_dir(&self) -> Result<PathBuf>

Returns the path to the suggested directory for your app’s data files.

Resolves to data_dir/${bundle_identifier}.

source

pub fn app_local_data_dir(&self) -> Result<PathBuf>

Returns the path to the suggested directory for your app’s local data files.

Resolves to local_data_dir/${bundle_identifier}.

source

pub fn app_cache_dir(&self) -> Result<PathBuf>

Returns the path to the suggested directory for your app’s cache files.

Resolves to cache_dir/${bundle_identifier}.

source

pub fn app_log_dir(&self) -> Result<PathBuf>

Returns the path to the suggested directory for your app’s log files.

§Platform-specific
  • Linux: Resolves to data_local_dir/${bundle_identifier}/logs.
  • macOS: Resolves to home_dir/Library/Logs/${bundle_identifier}
  • Windows: Resolves to data_local_dir/${bundle_identifier}/logs.
source

pub fn temp_dir(&self) -> Result<PathBuf>

A temporary directory. Resolves to std::env::temp_dir.

source§

impl<R: Runtime> PathResolver<R>

source

pub fn resolve<P: AsRef<Path>>( &self, path: P, base_directory: BaseDirectory ) -> Result<PathBuf>

Resolves the path with the base directory.

§Examples
use tauri::{path::BaseDirectory, Manager};
tauri::Builder::default()
  .setup(|app| {
    let path = app.path().resolve("path/to/something", BaseDirectory::Config)?;
    assert_eq!(path.to_str().unwrap(), "/home/${whoami}/.config/path/to/something");
    Ok(())
  });
source

pub fn parse<P: AsRef<Path>>(&self, path: P) -> Result<PathBuf>

Parse the given path, resolving a BaseDirectory variable if the path starts with one.

§Examples
use tauri::Manager;
tauri::Builder::default()
  .setup(|app| {
    let path = app.path().parse("$HOME/.bashrc")?;
    assert_eq!(path.to_str().unwrap(), "/home/${whoami}/.bashrc");
    Ok(())
  });

Auto Trait Implementations§

§

impl<R> Freeze for PathResolver<R>

§

impl<R> !RefUnwindSafe for PathResolver<R>

§

impl<R> Send for PathResolver<R>

§

impl<R> Sync for PathResolver<R>

§

impl<R> Unpin for PathResolver<R>

§

impl<R> !UnwindSafe for PathResolver<R>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.