pub struct FileUri {
pub uri: String,
pub document_top_tree_uri: Option<String>,
}Expand description
URI to represent a file or directory.
§TypeScript
type FileUri = {
uri: string,
documentTopTreeUri: string | null
}Fields§
§uri: StringURI pointing to a file or directory.
This uses either the content:// scheme or the file:// scheme.
document_top_tree_uri: Option<String>Tree URI of the origin directory to which this entry belongs.
This is present for directories obtained via a directory picker and for entries derived from them.
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_scheme(&self) -> bool
pub fn is_file_scheme(&self) -> bool
Indicates whether this is file:// URI.
Sourcepub fn is_content_scheme(&self) -> bool
pub fn is_content_scheme(&self) -> bool
Indicates whether this is content:// URI.
pub fn is_file_uri(&self) -> bool
Use is_file_scheme instead
pub fn is_content_uri(&self) -> bool
Use is_content_scheme instead