pub enum SafeFilePath {
Url(Url),
Path(SafePathBuf),
}
Expand description
Represents either a safe filesystem path or a URI pointing to a file
such as file://
URIs or Android content://
URIs.
Variants§
Url(Url)
file://
URIs or Android content://
URIs.
Path(SafePathBuf)
Safe PathBuf
, see `SafePathBuf``.
Implementations§
Source§impl SafeFilePath
impl SafeFilePath
Sourcepub fn as_path(&self) -> Option<&Path>
pub fn as_path(&self) -> Option<&Path>
Get a reference to the contained Path
if the variant is SafeFilePath::Path
.
Use SafeFilePath::into_path
to try to convert the SafeFilePath::Url
variant as well.
Sourcepub fn into_path(self) -> Result<PathBuf, Error>
pub fn into_path(self) -> Result<PathBuf, Error>
Try to convert into PathBuf
if possible.
This calls Url::to_file_path
if the variant is SafeFilePath::Url
,
otherwise returns the contained PathBuf as is.
Sourcepub fn simplified(self) -> Self
pub fn simplified(self) -> Self
Takes the contained PathBuf
if the variant is SafeFilePath::Path
,
and when possible, converts Windows UNC paths to regular paths.
Trait Implementations§
Source§impl Clone for SafeFilePath
impl Clone for SafeFilePath
Source§fn clone(&self) -> SafeFilePath
fn clone(&self) -> SafeFilePath
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SafeFilePath
impl Debug for SafeFilePath
Source§impl<'de> Deserialize<'de> for SafeFilePath
impl<'de> Deserialize<'de> for SafeFilePath
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for SafeFilePath
impl Display for SafeFilePath
Source§impl From<SafeFilePath> for FilePath
impl From<SafeFilePath> for FilePath
Source§fn from(value: SafeFilePath) -> Self
fn from(value: SafeFilePath) -> Self
Converts to this type from the input type.
Source§impl From<Url> for SafeFilePath
impl From<Url> for SafeFilePath
Source§impl FromStr for SafeFilePath
impl FromStr for SafeFilePath
Source§impl Serialize for SafeFilePath
impl Serialize for SafeFilePath
Source§impl TryFrom<&Path> for SafeFilePath
impl TryFrom<&Path> for SafeFilePath
Source§impl TryFrom<&PathBuf> for SafeFilePath
impl TryFrom<&PathBuf> for SafeFilePath
Source§impl TryFrom<FilePath> for SafeFilePath
impl TryFrom<FilePath> for SafeFilePath
Source§impl TryFrom<PathBuf> for SafeFilePath
impl TryFrom<PathBuf> for SafeFilePath
Auto Trait Implementations§
impl Freeze for SafeFilePath
impl RefUnwindSafe for SafeFilePath
impl Send for SafeFilePath
impl Sync for SafeFilePath
impl Unpin for SafeFilePath
impl UnwindSafe for SafeFilePath
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
Mutably borrows from an owned value. Read more