pytauri_core/ext_mod_impl/
path.rs1use std::path::PathBuf;
2
3use pyo3::prelude::*;
4use pyo3_utils::py_wrapper::{PyWrapper, PyWrapperT0};
5use tauri::path;
6
7use crate::{tauri_runtime::Runtime, utils::delegate_inner};
8
9type TauriPathResolver = path::PathResolver<Runtime>;
10
11#[pyclass(frozen)]
13#[non_exhaustive]
14pub struct PathResolver(PyWrapper<PyWrapperT0<TauriPathResolver>>);
15
16impl PathResolver {
17 pub(crate) fn new(path_resolver: TauriPathResolver) -> Self {
18 Self(PyWrapper::new0(path_resolver))
19 }
20}
21
22macro_rules! impl_path_resolver_method {
23 ($path_resolver:ident => : $($fn_name:ident),*) => {
24 #[pymethods]
25 impl $path_resolver {
26 $(
27 fn $fn_name(&self, py: Python<'_>) -> PyResult<PathBuf> {
28 py.allow_threads(|| delegate_inner!(self, $fn_name,))
30 }
31 )*
32 }
33 };
34
35}
36
37impl_path_resolver_method!(
38 PathResolver => :
39 audio_dir,
40 cache_dir,
41 config_dir,
42 data_dir,
43 local_data_dir,
44 desktop_dir,
45 document_dir,
46 download_dir,
47 executable_dir,
48 font_dir,
49 home_dir,
50 picture_dir,
51 public_dir,
52 runtime_dir,
53 template_dir,
54 video_dir,
55 resource_dir,
56 app_config_dir,
57 app_data_dir,
58 app_local_data_dir,
59 app_cache_dir,
60 app_log_dir,
61 temp_dir
62);