pub enum FilePath {
Url(Url),
Path(PathBuf),
}
Expand description
Represents either a filesystem path or a URI pointing to a file
such as file://
URIs or Android content://
URIs.
Variants§
Implementations§
Source§impl FilePath
impl FilePath
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 FilePath::Path
.
Use FilePath::into_path
to try to convert the FilePath::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 FilePath::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 FilePath::Path
,
and when possible, converts Windows UNC paths to regular paths.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for FilePath
impl<'de> Deserialize<'de> for FilePath
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 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.
Auto Trait Implementations§
impl Freeze for FilePath
impl RefUnwindSafe for FilePath
impl Send for FilePath
impl Sync for FilePath
impl Unpin for FilePath
impl UnwindSafe for FilePath
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