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
92
93
94
95
96
use crate::cell::Cell;
use crate::event::{Event, Weights};
pub use crate::distance::Distance;
pub use crate::neighbour_search::{NeighbourSearch, NeighbourSearchAlgo};
pub use crate::seeds::SelectSeeds;
/// Update event weights
pub trait UpdateWeights {
/// Error updating weights
type Error;
/// Update all event weights
fn update_all_weights(
&mut self,
weights: &[Weights],
) -> Result<usize, Self::Error>;
/// Update the weights for the next event
fn update_next_weights(
&mut self,
weights: &Weights,
) -> Result<bool, Self::Error>;
/// Finish updating weights
fn finish_weight_update(&mut self) -> Result<(), Self::Error> {
Ok(())
}
}
/// Rewind to the beginning of a stream
pub trait Rewind {
/// Error during rewinding
type Error;
/// Rewind to the beginning of a stream
fn rewind(&mut self) -> Result<(), Self::Error>;
}
/// Express event in terms of IRC safe objects
pub trait Clustering {
/// Error
type Error;
/// Express event in terms of IRC safe objects
fn cluster(&self, ev: Event) -> Result<Event, Self::Error>;
}
/// Convert between two types
///
/// In contrast to [std::convert::TryFrom] the converter can maintain
/// internal state.
pub trait TryConvert<From, To> {
/// Conversion error
type Error;
/// Convert between two types
fn try_convert(&self, f: From) -> Result<To, Self::Error>;
}
/// Resample events
pub trait Resample {
/// Resampling error
type Error;
/// Resample events
fn resample(&mut self, e: Vec<Event>) -> Result<Vec<Event>, Self::Error>;
}
/// Unweight events
pub trait Unweight {
/// Unweighting error
type Error;
/// Unweight events
fn unweight(&mut self, e: Vec<Event>) -> Result<Vec<Event>, Self::Error>;
}
/// Callback after resampling a cell
pub trait ObserveCell {
/// Look at the new cell
fn observe_cell(&self, cell: &Cell);
/// Called after the resampling is completed
///
/// For example, this can be used to write out statistics.
/// The default is to do nothing.
fn finish(&mut self) {}
}
/// Progress indicator, e.g. a progress bar
pub trait Progress {
/// Advance the progress by `i`
fn inc(&self, i: u64);
/// Signal that we are done
fn finish(&self);
}