use std::{
path::{Path, PathBuf},
str::FromStr,
};
use url::{ParseError, Url};
pub mod third_party;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ResourcePath {
pub remote: Url,
pub local: PathBuf,
}
impl ResourcePath {
pub fn new<N, L>(remote: N, local: L) -> Result<Self, ParseError>
where
N: AsRef<str>,
L: AsRef<Path>,
{
Ok(Self { remote: Url::from_str(remote.as_ref())?, local: local.as_ref().to_path_buf() })
}
pub fn with_local<P: AsRef<Path>>(mut self, local: P) -> Self {
self.local = local.as_ref().to_path_buf();
self
}
pub fn with_remote<P: AsRef<str>>(mut self, remote: P) -> Result<Self, ParseError> {
self.remote = Url::from_str(remote.as_ref())?;
Ok(self)
}
}