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
sourceimpl 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.
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(())
});
Trait Implementations
sourceimpl Clone for PathResolver
impl Clone for PathResolver
sourcefn clone(&self) -> PathResolver
fn clone(&self) -> PathResolver
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for PathResolver
impl Send for PathResolver
impl Sync for PathResolver
impl Unpin for PathResolver
impl UnwindSafe for PathResolver
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more