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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
use rattler_conda_types::{PrefixRecord, RepoDataRecord};
use crate::install::Transaction;
/// A trait for reporting progress of the installation process.
pub trait Reporter: Send + Sync {
/// Called when the transaction starts. This is the first method called.
fn on_transaction_start(&self, transaction: &Transaction<PrefixRecord, RepoDataRecord>);
/// Called when a transaction operation starts. During the operation the
/// cache is populated, previous installations are uninstalled and new
/// installations are linked.
///
/// The `operation` is the index of the operation in the transaction passed
/// to `on_transaction_start`.
fn on_transaction_operation_start(&self, operation: usize);
/// Called when starting to populate the cache for a package. This is called
/// for any new package that will be installed. Before installation any
/// package is first added to the cache.
///
/// The `operation` is the index of the operation in the transaction passed
/// to `on_transaction_start`.
fn on_populate_cache_start(&self, operation: usize, record: &RepoDataRecord) -> usize;
/// Called when validation of a package starts. If a package is already
/// present in the cache, the contents of the package is validated
/// against its manifest, this is done to ensure that the package is not
/// corrupted.
fn on_validate_start(&self, cache_entry: usize) -> usize;
/// Called when validation completes. If the package is valid, the package
/// is immediately used and no downloading is required.
///
/// The `validate_idx` is the value return by `on_validate_start` for the
/// corresponding package.
fn on_validate_complete(&self, validate_idx: usize);
/// Called when a download starts. If a package is not present in the cache
/// or the package in the cache is corrupt, the package is downloaded. This
/// function is called right before that happens.
///
/// The value returned by this function is passed as the `download_idx` to
/// `on_download_progress` and `on_download_complete`.
///
/// The `cache_entry` is the value return by `on_populate_cache_start` for
/// the corresponding package.
fn on_download_start(&self, cache_entry: usize) -> usize;
/// Called with regular updates on the download progress.
///
/// The `download_idx` is the value return by `on_download_start` for the
/// corresponding download.
fn on_download_progress(&self, download_idx: usize, progress: u64, total: Option<u64>);
/// Called when a download completes.
///
/// The `download_idx` is the value return by `on_download_start` for the
/// corresponding download.
fn on_download_completed(&self, download_idx: usize);
/// Called when the cache for a package was populated
///
/// The `cache_entry` is the value return by `on_populate_cache_start` for
/// the corresponding package.
fn on_populate_cache_complete(&self, cache_entry: usize);
/// Called when an unlink operation started.
///
/// The `operation` is the index of the operation in the transaction passed
/// to `on_transaction_start`.
fn on_unlink_start(&self, operation: usize, record: &PrefixRecord) -> usize;
/// Called when an unlink operation completed.
///
/// The `index` is the value return by `on_unlink_start` for the
/// corresponding package.
fn on_unlink_complete(&self, index: usize);
/// Called when linking of a package has started
///
/// The `operation` is the index of the operation in the transaction passed
/// to `on_transaction_start`.
fn on_link_start(&self, operation: usize, record: &RepoDataRecord) -> usize;
/// Called when linking of a package completed.
///
/// The `index` is the value return by `on_link_start` for the corresponding
/// package.
fn on_link_complete(&self, index: usize);
/// Called when a transaction operation finishes.
fn on_transaction_operation_complete(&self, operation: usize);
/// Called when the transaction completes. Unless an error occurs, this is
/// the last function that is called.
fn on_transaction_complete(&self);
/// Called when a post-link script starts execution.
///
/// The `package_name` is the name of the package whose post-link script is
/// being executed.
/// The `script_path` is the relative path to the script within the prefix.
///
/// Returns an index that will be passed to `on_post_link_complete`.
fn on_post_link_start(&self, package_name: &str, script_path: &str) -> usize;
/// Called when a post-link script completes execution.
///
/// The `index` is the value returned by `on_post_link_start` for the
/// corresponding script.
/// The `success` parameter indicates whether the script executed successfully.
fn on_post_link_complete(&self, index: usize, success: bool);
/// Called when a pre-unlink script starts execution.
///
/// The `package_name` is the name of the package whose pre-unlink script is
/// being executed.
/// The `script_path` is the relative path to the script within the prefix.
///
/// Returns an index that will be passed to `on_pre_unlink_complete`.
fn on_pre_unlink_start(&self, package_name: &str, script_path: &str) -> usize;
/// Called when a pre-unlink script completes execution.
///
/// The `index` is the value returned by `on_pre_unlink_start` for the
/// corresponding script.
/// The `success` parameter indicates whether the script executed successfully.
fn on_pre_unlink_complete(&self, index: usize, success: bool);
}