1use crate::{package::RemotePackage, PackageName};
2
3#[cfg(all(feature = "indicatif", feature = "library"))]
4pub use self::indicatif::IndicatifCallback;
5pub use self::plain::PlainCallback;
6pub use self::silent::SilentCallback;
7#[cfg(feature = "library")]
8use crate::{backend::Error, PackageList};
9#[cfg(all(feature = "indicatif", feature = "library"))]
10mod indicatif;
11mod plain;
12mod silent;
13
14pub trait Callback {
16 fn fetch_start(&mut self, initial_count: usize);
17 fn fetch_package_name(&mut self, pkg_name: &PackageName);
18 fn fetch_package_increment(&mut self, added_processed: usize, added_count: usize);
19 fn fetch_end(&mut self);
20
21 #[cfg(feature = "library")]
22 fn install_prompt(&mut self, list: &PackageList) -> Result<(), Error>;
23 #[cfg(feature = "library")]
24 fn install_check_conflict(
25 &mut self,
26 list: &Vec<pkgar::TransactionConflict>,
27 ) -> Result<(), Error>;
28 fn install_extract(&mut self, pkg_name: &RemotePackage);
29
30 fn download_start(&mut self, length: u64, file: &str);
31 fn download_increment(&mut self, downloaded: u64);
32 fn download_end(&mut self);
33
34 #[cfg(feature = "library")]
35 fn commit_start(&mut self, count: usize);
36 #[cfg(feature = "library")]
37 fn commit_increment(&mut self, file: &pkgar::Transaction);
38 #[cfg(feature = "library")]
39 fn commit_end(&mut self);
40
41 #[cfg(feature = "library")]
42 fn abort_start(&mut self, count: usize);
43 #[cfg(feature = "library")]
44 fn abort_increment(&mut self, file: &pkgar::Transaction);
45 #[cfg(feature = "library")]
46 fn abort_end(&mut self);
47}