pub struct FileUri {
pub uri: String,
pub document_top_tree_uri: Option<String>,
}Expand description
Path to represent a file or directory.
§Note
For compatibility, an interconversion to tauri_plugin_fs::FilePath is implemented, such as follwing.
This is lossy and also not guaranteed to work properly with other plugins.
However, reading and writing files by official tauri_plugin_fs etc. should work well.
use tauri_plugin_android_fs::FileUri;
use tauri_plugin_fs::FilePath;
let uri: FileUri = unimplemented!();
let path: FilePath = uri.into();
let uri: FileUri = path.into();§Typescript type
type FileUri = {
uri: string, // This can use as path for official tauri_plugin_fs
documentTopTreeUri: string | null
}Fields§
§uri: String§document_top_tree_uri: Option<String>Implementations§
Source§impl FileUri
impl FileUri
Sourcepub fn to_json_string(&self) -> Result<String>
pub fn to_json_string(&self) -> Result<String>
Same as serde_json::to_string(...)
Sourcepub fn from_json_str(json: impl AsRef<str>) -> Result<Self>
pub fn from_json_str(json: impl AsRef<str>) -> Result<Self>
Same as serde_json::from_str(...)
pub fn from_uri(uri: impl Into<String>) -> Self
Sourcepub fn from_path(path: impl AsRef<Path>) -> Self
pub fn from_path(path: impl AsRef<Path>) -> Self
Constructs a URI from the absolute path of a file or directory.
This must be an absolute path that does not contain ./ or ../.
Even if the path is invalid, it will not cause an error or panic; an invalid URI will be returned.
§Note
There are a few points to note regarding this.
- This URI cannot be passed to functions of
FileOpenerfor sending to other apps. - Operations using this URI may fall back to
std::fsinstead of Kotlin API.
Sourcepub fn to_path(&self) -> Option<PathBuf>
pub fn to_path(&self) -> Option<PathBuf>
If this URI is an Android file-scheme URI, for example,
via FileUri::from_path, its absolute path will be retrieved.
Sourcepub fn is_file_uri(&self) -> bool
pub fn is_file_uri(&self) -> bool
Indicates whether this is file:// URI.
Sourcepub fn is_content_uri(&self) -> bool
pub fn is_content_uri(&self) -> bool
Indicates whether this is content:// URI.