1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#![forbid(missing_docs)]
#![doc = include_str!("../Readme.md")]
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)
}
}