1use std::{
2 path::{Path, PathBuf},
3 str::FromStr,
4};
5
6use url::{ParseError, Url};
7
8pub mod third_party;
9
10#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
12pub struct ResourcePath {
13 pub remote: Url,
15 pub local: PathBuf,
17}
18
19impl ResourcePath {
20 pub fn new<N, L>(remote: N, local: L) -> Result<Self, ParseError>
22 where
23 N: AsRef<str>,
24 L: AsRef<Path>,
25 {
26 Ok(Self { remote: Url::from_str(remote.as_ref())?, local: local.as_ref().to_path_buf() })
27 }
28 pub fn with_local<P: AsRef<Path>>(mut self, local: P) -> Self {
30 self.local = local.as_ref().to_path_buf();
31 self
32 }
33 pub fn with_remote<P: AsRef<str>>(mut self, remote: P) -> Result<Self, ParseError> {
35 self.remote = Url::from_str(remote.as_ref())?;
36 Ok(self)
37 }
38}