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) -> FilePath
pub fn simplified(self) -> FilePath
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<FilePath, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<FilePath, <D as Deserializer<'de>>::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) -> FilePath
fn from(value: SafeFilePath) -> FilePath
Converts to this type from the input type.
Source§impl Serialize for FilePath
impl Serialize for FilePath
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
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