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
use std::sync::Mutex;
use tor_linkspec::OwnedChanTarget;
#[derive(Debug, Default)]
pub(super) struct Path {
hops: Mutex<Vec<OwnedChanTarget>>,
}
impl Path {
pub(super) fn n_hops(&self) -> usize {
self.hops.lock().expect("poisoned lock").len()
}
pub(super) fn push_hop(&self, target: OwnedChanTarget) {
self.hops.lock().expect("poisoned lock").push(target);
}
pub(super) fn first_hop(&self) -> Option<OwnedChanTarget> {
self.hops
.lock()
.expect("poisoned lock")
.get(0)
.map(Clone::clone)
}
pub(super) fn all_hops(&self) -> Vec<OwnedChanTarget> {
self.hops.lock().expect("poisoned lock").clone()
}
}