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
//! Models about index metadata update process
use crate::FilterId;
/// Result of index metadata update
pub struct PullMetadataResult {
/// List of filters added in the update
pub added_filters: Vec<FilterId>,
/// List of filters removed in the update
pub removed_filters: Vec<FilterId>,
/// List of filters moved in the update
pub moved_filters: Vec<MovedFilterInfo>,
}
impl PullMetadataResult {
/// Creates a new empty `PullMetadataResult`
pub const fn new() -> Self {
Self {
added_filters: vec![],
removed_filters: vec![],
moved_filters: vec![],
}
}
/// Creates a new `PullMetadataResult` with the given `added_filters`
///
/// The `removed_filters` and `moved_filters` fields are initialized as empty vectors.
///
pub fn new_with_added_filters(added_filters: Vec<FilterId>) -> Self {
Self {
added_filters,
removed_filters: vec![],
moved_filters: vec![],
}
}
}
/// Information about filter movement during index metadata update
pub struct MovedFilterInfo {
/// Previous id of the filter
pub previous_id: FilterId,
/// New id of the filter
pub new_id: FilterId,
}
impl MovedFilterInfo {
/// Creates a new `MovedFilterInfo` with the given `previous_id` and `new_id`
///
/// # Arguments
///
/// * `previous_id` - Previous id of the filter
/// * `new_id` - New id of the filter
///
/// # Returns
///
/// A new `MovedFilterInfo`
pub(crate) fn new(previous_id: FilterId, new_id: FilterId) -> Self {
Self {
previous_id,
new_id,
}
}
}