Struct tauri::PathResolver
source · pub struct PathResolver { /* private fields */ }
Expand description
The path resolver is a helper for the application-specific crate::api::path
APIs.
Implementations§
source§impl PathResolver
impl PathResolver
sourcepub fn resource_dir(&self) -> Option<PathBuf>
pub fn resource_dir(&self) -> Option<PathBuf>
Returns the path to the resource directory of this app.
Helper function for crate::api::path::resource_dir
.
sourcepub fn resolve_resource<P: AsRef<Path>>(&self, path: P) -> Option<PathBuf>
pub fn resolve_resource<P: AsRef<Path>>(&self, path: P) -> Option<PathBuf>
Resolves the path of the given resource.
Note that the path must be the same as provided in tauri.conf.json
.
This function is helpful when your resource path includes a root dir (/
) or parent component (..
),
because Tauri replaces them with a parent folder, so simply using Self::resource_dir
and joining the path
won’t work.
§Examples
tauri.conf.json
:
{
"tauri": {
"bundle": {
"resources": ["../assets/*"]
}
}
}
tauri::Builder::default()
.setup(|app| {
let resource_path = app.path_resolver()
.resolve_resource("../assets/logo.svg")
.expect("failed to resolve resource dir");
Ok(())
});
sourcepub fn app_config_dir(&self) -> Option<PathBuf>
pub fn app_config_dir(&self) -> Option<PathBuf>
Returns the path to the suggested directory for your app’s config files.
Helper function for crate::api::path::app_config_dir
.
sourcepub fn app_data_dir(&self) -> Option<PathBuf>
pub fn app_data_dir(&self) -> Option<PathBuf>
Returns the path to the suggested directory for your app’s data files.
Helper function for crate::api::path::app_data_dir
.
sourcepub fn app_local_data_dir(&self) -> Option<PathBuf>
pub fn app_local_data_dir(&self) -> Option<PathBuf>
Returns the path to the suggested directory for your app’s local data files.
Helper function for crate::api::path::app_local_data_dir
.
sourcepub fn app_cache_dir(&self) -> Option<PathBuf>
pub fn app_cache_dir(&self) -> Option<PathBuf>
Returns the path to the suggested directory for your app’s cache files.
Helper function for crate::api::path::app_cache_dir
.
sourcepub fn app_log_dir(&self) -> Option<PathBuf>
pub fn app_log_dir(&self) -> Option<PathBuf>
Returns the path to the suggested directory for your app’s log files.
Helper function for crate::api::path::app_log_dir
.
Trait Implementations§
source§impl Clone for PathResolver
impl Clone for PathResolver
source§fn clone(&self) -> PathResolver
fn clone(&self) -> PathResolver
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for PathResolver
impl RefUnwindSafe for PathResolver
impl Send for PathResolver
impl Sync for PathResolver
impl Unpin for PathResolver
impl UnwindSafe for PathResolver
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)