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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
use tor_proto::circuit::UniqId;
use crate::Error;
#[derive(Debug)]
pub struct DirResponse {
status: u16,
output: String,
error: Option<Error>,
source: Option<SourceInfo>,
}
#[derive(Debug, Clone)]
pub struct SourceInfo {
circuit: UniqId,
}
impl DirResponse {
pub(crate) fn new(
status: u16,
error: Option<Error>,
output: String,
source: Option<SourceInfo>,
) -> Self {
DirResponse {
status,
output,
error,
source,
}
}
pub fn status_code(&self) -> u16 {
self.status
}
pub fn is_partial(&self) -> bool {
self.error.is_some()
}
pub fn error(&self) -> Option<&Error> {
self.error.as_ref()
}
pub fn output(&self) -> &str {
&self.output
}
pub fn into_output(self) -> String {
self.output
}
pub fn source(&self) -> Option<&SourceInfo> {
self.source.as_ref()
}
}
impl SourceInfo {
pub(crate) fn new(circuit: UniqId) -> Self {
SourceInfo { circuit }
}
pub fn unique_circ_id(&self) -> &UniqId {
&self.circuit
}
}