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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use std::path::PathBuf;
#[derive(Debug, Eq, PartialEq)]
pub struct RetrievedDocument {
document: Document,
retrieval_location: RetrievalLocation,
}
impl RetrievedDocument {
pub fn new(document: Document, retrieval_location: RetrievalLocation) -> Self {
Self {
document,
retrieval_location,
}
}
pub fn into_document(self) -> Document {
self.document
}
pub fn retrieval_location(&self) -> &RetrievalLocation {
&self.retrieval_location
}
}
#[derive(Debug, Eq, PartialEq)]
pub struct Document {
buffer: Vec<u8>,
}
impl Document {
pub fn new(buffer: Vec<u8>) -> Self {
Self { buffer }
}
pub fn buffer(&self) -> &[u8] {
&self.buffer
}
pub fn into_buffer(self) -> Vec<u8> {
self.buffer
}
}
#[derive(Debug, Eq, PartialEq)]
pub enum RetrievalLocation {
RemoteUrl(String),
Cache(PathBuf),
}