pub enum FileUrl {
Url(Url),
Path(Utf8PathBuf),
}Expand description
A URL or local file path that points to a package source.
The parser accepts both proper URLs ("https://...") and file://
prefixed local paths.
let url = FileUrl::try_from_url(
"https://thunderstore.io/package/download/denikson/BepInExPack_Valheim/5.4.2202/",
).unwrap();
assert!(url.to_string().starts_with("https://"));
let local: FileUrl = "file:///home/user/.config/loadsmith/cache/BepInExPack_Valheim-5.4.2202.zip"
.parse().unwrap();
assert_eq!(
local.to_string(),
"file:///home/user/.config/loadsmith/cache/BepInExPack_Valheim-5.4.2202.zip",
);Variants§
Url(Url)
Path(Utf8PathBuf)
Implementations§
Source§impl FileUrl
impl FileUrl
Sourcepub fn try_from_url(s: &str) -> Result<Self>
pub fn try_from_url(s: &str) -> Result<Self>
Parse a string as a proper URL.
This does not recognise file:// prefixes. To handle both forms,
use FromStr instead.
let url = FileUrl::try_from_url("https://thunderstore.io/api/v1/package/").unwrap();
assert!(url.to_string().starts_with("https://"));Trait Implementations§
Source§impl<'de> Deserialize<'de> for FileUrl
impl<'de> Deserialize<'de> for FileUrl
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
impl Eq for FileUrl
Source§impl From<Utf8PathBuf> for FileUrl
impl From<Utf8PathBuf> for FileUrl
Source§fn from(path: Utf8PathBuf) -> Self
fn from(path: Utf8PathBuf) -> Self
Converts to this type from the input type.
impl StructuralPartialEq for FileUrl
Auto Trait Implementations§
impl Freeze for FileUrl
impl RefUnwindSafe for FileUrl
impl Send for FileUrl
impl Sync for FileUrl
impl Unpin for FileUrl
impl UnsafeUnpin for FileUrl
impl UnwindSafe for FileUrl
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