1use std::path::Path;
5use std::sync::Arc;
6
7#[derive(Debug)]
9pub struct Source {
10 pub urls: Arc<[Box<str>]>,
12
13 pub dest: Arc<Path>,
15
16 pub part: Option<Arc<Path>>,
18}
19
20impl Source {
21 pub fn builder(dest: Arc<Path>, url: Box<str>) -> SourceBuilder {
22 SourceBuilder::new(dest, url)
23 }
24
25 pub fn new(urls: Arc<[Box<str>]>, dest: Arc<Path>) -> Self {
26 Self {
27 urls,
28 dest,
29 part: None,
30 }
31 }
32
33 pub fn set_part(&mut self, part: Option<Arc<Path>>) {
35 self.part = part;
36 }
37}
38
39pub struct SourceBuilder {
41 urls: Vec<Box<str>>,
42 dest: Arc<Path>,
43 part: Option<Arc<Path>>,
44}
45
46impl SourceBuilder {
47 pub fn new(dest: Arc<Path>, url: Box<str>) -> Self {
48 SourceBuilder {
49 dest,
50 urls: vec![url],
51 part: None,
52 }
53 }
54
55 pub fn append_url(mut self, url: Box<str>) -> Self {
57 self.urls.push(url);
58 self
59 }
60
61 pub fn partial(mut self, part: Arc<Path>) -> Self {
63 self.part = Some(part);
64 self
65 }
66
67 pub fn build(self) -> Source {
68 Source {
69 urls: Arc::from(self.urls),
70 dest: self.dest,
71 part: self.part,
72 }
73 }
74}