Debian Codegraph @

src/progress.rs

raw symbols SCIP
1 //! Contains Progress struct for updating the package list.
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Write# as _;
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{stdoutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/stdout()., Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#};
4 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/::Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#;
5
6 use cxxrust-analyzer cargo cxx 1.0.199 crate/::{ExternTyperust-analyzer cargo cxx 1.0.199 extern_type/ExternType#, UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#};
7
8 use craterust-analyzer cargo rust-apt 0.8.0 crate/::configrust-analyzer cargo rust-apt 0.8.0 config/::Configrust-analyzer cargo rust-apt 0.8.0 config/Config#;
9 use craterust-analyzer cargo rust-apt 0.8.0 crate/::errorrust-analyzer cargo rust-apt 0.8.0 error/::rawrust-analyzer cargo rust-apt 0.8.0 error/raw/::pending_errorrust-analyzer cargo rust-apt 0.8.0 error/raw/pending_error().;
10 use craterust-analyzer cargo rust-apt 0.8.0 crate/::rawrust-analyzer cargo rust-apt 0.8.0 raw/::{acquire_statusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/acquire_status()., AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#, ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#, ItemStaterust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemState#, PkgAcquirerust-analyzer cargo rust-apt 0.8.0 acquire/raw/PkgAcquire#};
11 use craterust-analyzer cargo rust-apt 0.8.0 crate/::utilrust-analyzer cargo rust-apt 0.8.0 util/::{
12 get_apt_progress_stringrust-analyzer cargo rust-apt 0.8.0 util/get_apt_progress_string()., terminal_heightrust-analyzer cargo rust-apt 0.8.0 util/terminal_height()., terminal_widthrust-analyzer cargo rust-apt 0.8.0 util/terminal_width()., time_strrust-analyzer cargo rust-apt 0.8.0 util/time_str()., unit_strrust-analyzer cargo rust-apt 0.8.0 util/unit_str()., NumSysrust-analyzer cargo rust-apt 0.8.0 util/NumSys#,
13 };
14
15 /// Customize the output shown during file downloads.
16 pub trait DynAcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress# {
17 /// Called on c++ to set the pulse interval.
18 fn pulse_intervalrust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress#pulse_interval().(&self) -> usize;
19
20 /// Called when an item is confirmed to be up-to-date.
21 fn hitrust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress#hit().(&mut self, item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#);
22
23 /// Called when an Item has started to download
24 fn fetchrust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress#fetch().(&mut self, item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#);
25
26 /// Called when an Item fails to download
27 fn failrust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress#fail().(&mut self, item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#);
28
29 /// Called periodically to provide the overall progress information
30 fn pulserust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress#pulse().(&mut self, status: &AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#, owner: &PkgAcquirerust-analyzer cargo rust-apt 0.8.0 acquire/raw/PkgAcquire#);
31
32 /// Called when an item is successfully and completely fetched.
33 fn donerust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress#done().(&mut self, item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#);
34
35 /// Called when progress has started
36 fn startrust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress#start().(&mut self);
37
38 /// Called when progress has finished
39 fn stoprust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress#stop().(&mut self, status: &AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#);
40 }
41
42 /// Customize the output of operation progress on things like opening the cache.
43 pub trait DynOperationProgressrust-analyzer cargo rust-apt 0.8.0 progress/DynOperationProgress# {
44 fn updaterust-analyzer cargo rust-apt 0.8.0 progress/DynOperationProgress#update().(&mut self, operation: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, percent: f32);
45 fn donerust-analyzer cargo rust-apt 0.8.0 progress/DynOperationProgress#done().(&mut self);
46 }
47
48 /// Customize the output of installation progress.
49 pub trait DynInstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/DynInstallProgress# {
50 fn status_changedrust-analyzer cargo rust-apt 0.8.0 progress/DynInstallProgress#status_changed().(
51 &mut self,
52 pkgname: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
53 steps_done: u64,
54 total_steps: u64,
55 action: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
56 );
57 fn errorrust-analyzer cargo rust-apt 0.8.0 progress/DynInstallProgress#error().(&mut self, pkgname: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, steps_done: u64, total_steps: u64, error: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#);
58 }
59
60 /// A struct aligning with `apt`'s AcquireStatus.
61 ///
62 /// This struct takes a struct with impl AcquireProgress
63 /// It sets itself as the callback from C++ AcqTextStatus
64 /// which will then call the functions on this struct.
65 /// This struct will then forward those calls to your struct via
66 /// trait methods.
67 pub struct AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#<'a> {
68 statusrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#status.: UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#<AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#>,
69 innerrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#inner.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn DynAcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress# + 'a>,
70 }
71
72 impl<'a> AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#<'a> {
73 /// Create a new AcquireProgress Struct from a struct that implements
74 /// AcquireProgress trait.
75 pub fn newrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]new().(inner: impl DynAcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress# + 'a) -> Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`] {
76 Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`] {
77 statusrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#status.: unsafe { acquire_statusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/acquire_status().() },
78 innerrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#inner.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(inner),
79 }
80 }
81
82 /// Create a new AcquireProgress Struct with the default `apt`
83 /// implementation.
84 pub fn aptrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]apt().() -> Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`] { Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]::newrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]new().(AptAcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#::newrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress]new().()) }
85
86 /// Create a new AcquireProgress Struct that outputs nothing.
87 pub fn quietrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]quiet().() -> Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`] { Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]::newrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]new().(AptAcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#::disablerust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress]disable().()) }
88
89 /// Sets AcquireProgress as the AcqTextStatus callback and
90 /// returns a Pinned mutable reference to AcqTextStatus.
91 pub fn mut_statusrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]mut_status().(&mut self) -> Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#> {
92 unsafe {
93 // Create raw mutable pointer to ourself
94 let raw_ptr = &mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().(self as *mut AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#);
95 // Pin AcqTextStatus in place so it is not moved in memory
96 // Segfault can occur if it is moved
97 let mut status = self.statusrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#status..pin_mutrust-analyzer cargo cxx 1.0.199 unique_ptr/impl#[`UniquePtr<T>`]pin_mut().();
98
99 // Set our raw pointer we created as the callback for C++ AcqTextStatus.
100 // AcqTextStatus will then be fed into libapt who will call its methods
101 // providing information. AcqTextStatus then uses this pointer to send that
102 // information back to rust on this struct. This struct will then send it
103 // through the trait methods on the `inner` object.
104 status.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`]as_mut().().set_callbackrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]set_callback().(raw_ptr);
105 status
106 }
107 }
108
109 /// Called on c++ to set the pulse interval.
110 pub(craterust-analyzer cargo rust-apt 0.8.0 crate/) fn pulse_intervalrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]pulse_interval().(&mut self) -> usize { self.innerrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#inner..pulse_intervalrust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress#pulse_interval().() }
111
112 /// Called when an item is confirmed to be up-to-date.
113 pub(craterust-analyzer cargo rust-apt 0.8.0 crate/) fn hitrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]hit().(&mut self, item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#) { self.innerrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#inner..hitrust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress#hit().(item) }
114
115 /// Called when an Item has started to download
116 pub(craterust-analyzer cargo rust-apt 0.8.0 crate/) fn fetchrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]fetch().(&mut self, item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#) { self.innerrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#inner..fetchrust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress#fetch().(item) }
117
118 /// Called when an Item fails to download
119 pub(craterust-analyzer cargo rust-apt 0.8.0 crate/) fn failrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]fail().(&mut self, item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#) { self.innerrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#inner..failrust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress#fail().(item) }
120
121 /// Called periodically to provide the overall progress information
122 pub(craterust-analyzer cargo rust-apt 0.8.0 crate/) fn pulserust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]pulse().(&mut self, owner: &PkgAcquirerust-analyzer cargo rust-apt 0.8.0 acquire/raw/PkgAcquire#) { self.innerrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#inner..pulserust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress#pulse().(&self.statusrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#status., owner) }
123
124 /// Called when progress has started
125 pub(craterust-analyzer cargo rust-apt 0.8.0 crate/) fn startrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]start().(&mut self) { self.innerrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#inner..startrust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress#start().() }
126
127 /// Called when an item is successfully and completely fetched.
128 pub(craterust-analyzer cargo rust-apt 0.8.0 crate/) fn donerust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]done().(&mut self, item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#) { self.innerrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#inner..donerust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress#done().(item) }
129
130 /// Called when progress has finished
131 pub(craterust-analyzer cargo rust-apt 0.8.0 crate/) fn stoprust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]stop().(&mut self) { self.innerrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#inner..stoprust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress#stop().(&self.statusrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#status.) }
132 }
133
134 impl<'a> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#<'a> {
135 fn defaultrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`][Default]default().() -> Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`][Default] { Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`][Default]::aptrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]apt().() }
136 }
137
138 /// Impl for sending AcquireProgress across the barrier.
139 unsafe impl<'a> ExternTyperust-analyzer cargo cxx 1.0.199 extern_type/ExternType# for AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#<'a> {
140 type Idrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`][ExternType]Id# = cxxrust-analyzer cargo cxx 1.0.199 crate/::type_idrust-analyzer cargo cxx 1.0.199 type_id/type_id!!("AcquireProgress");
141 type Kindrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`][ExternType]Kind# = cxxrust-analyzer cargo cxx 1.0.199 crate/::kindrust-analyzer cargo cxx 1.0.199 extern_type/kind/::Trivialrust-analyzer cargo cxx 1.0.199 extern_type/kind/Trivial#;
142 }
143
144 /// Allows lengthy operations to communicate their progress.
145 ///
146 /// The [`Default`] and only implementation of this is
147 /// [`self::OperationProgress::quiet`].
148 pub struct OperationProgressrust-analyzer cargo rust-apt 0.8.0 progress/OperationProgress#<'a> {
149 innerrust-analyzer cargo rust-apt 0.8.0 progress/OperationProgress#inner.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn DynOperationProgressrust-analyzer cargo rust-apt 0.8.0 progress/DynOperationProgress# + 'a>,
150 }
151
152 impl<'a> OperationProgressrust-analyzer cargo rust-apt 0.8.0 progress/OperationProgress#<'a> {
153 /// Create a new OpProgress Struct from a struct that implements
154 /// AcquireProgress trait.
155 pub fn newrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`]new().(inner: impl DynOperationProgressrust-analyzer cargo rust-apt 0.8.0 progress/DynOperationProgress# + 'static) -> Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`] {
156 Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`] {
157 innerrust-analyzer cargo rust-apt 0.8.0 progress/OperationProgress#inner.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(inner),
158 }
159 }
160
161 /// Returns a OperationProgress that outputs no data
162 ///
163 /// Generally I have not found much use for displaying OpProgress
164 pub fn quietrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`]quiet().() -> Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`] { Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`]::newrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`]new().(NoOpProgressrust-analyzer cargo rust-apt 0.8.0 progress/NoOpProgress# {}) }
165
166 /// Called when an operation has been updated.
167 fn updaterust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`]update().(&mut self, operation: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, percent: f32) { self.innerrust-analyzer cargo rust-apt 0.8.0 progress/OperationProgress#inner..updaterust-analyzer cargo rust-apt 0.8.0 progress/DynOperationProgress#update().(operation, percent) }
168
169 /// Called when an operation has finished.
170 fn donerust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`]done().(&mut self) { self.innerrust-analyzer cargo rust-apt 0.8.0 progress/OperationProgress#inner..donerust-analyzer cargo rust-apt 0.8.0 progress/DynOperationProgress#done().() }
171
172 pub fn pinrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`]pin().(&mut self) -> Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut OperationProgressrust-analyzer cargo rust-apt 0.8.0 progress/OperationProgress#<'a>> { Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`]new().(self) }
173 }
174
175 impl<'a> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for OperationProgressrust-analyzer cargo rust-apt 0.8.0 progress/OperationProgress#<'a> {
176 fn defaultrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`][Default]default().() -> Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`][Default] { Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`][Default]::quietrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`]quiet().() }
177 }
178
179 /// Impl for sending AcquireProgress across the barrier.
180 unsafe impl<'a> ExternTyperust-analyzer cargo cxx 1.0.199 extern_type/ExternType# for OperationProgressrust-analyzer cargo rust-apt 0.8.0 progress/OperationProgress#<'a> {
181 type Idrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`][ExternType]Id# = cxxrust-analyzer cargo cxx 1.0.199 crate/::type_idrust-analyzer cargo cxx 1.0.199 type_id/type_id!!("OperationProgress");
182 type Kindrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`][ExternType]Kind# = cxxrust-analyzer cargo cxx 1.0.199 crate/::kindrust-analyzer cargo cxx 1.0.199 extern_type/kind/::Trivialrust-analyzer cargo cxx 1.0.199 extern_type/kind/Trivial#;
183 }
184
185 /// Struct for displaying Progress of Package Installation.
186 ///
187 /// The [`Default`] implementation mirrors apt's.
188 pub struct InstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/InstallProgress#<'a> {
189 innerrust-analyzer cargo rust-apt 0.8.0 progress/InstallProgress#inner.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn DynInstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/DynInstallProgress# + 'a>,
190 }
191
192 impl<'a> InstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/InstallProgress#<'a> {
193 /// Create a new OpProgress Struct from a struct that implements
194 /// AcquireProgress trait.
195 pub fn newrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`]new().(inner: impl DynInstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/DynInstallProgress# + 'static) -> Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`] {
196 Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`] {
197 innerrust-analyzer cargo rust-apt 0.8.0 progress/InstallProgress#inner.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(inner),
198 }
199 }
200
201 /// Returns a OperationProgress that outputs no data
202 ///
203 /// Generally I have not found much use for displaying OpProgress
204 pub fn aptrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`]apt().() -> Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`] { Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`]::newrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`]new().(AptInstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/AptInstallProgress#::newrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptInstallProgress]new().()) }
205
206 fn status_changedrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`]status_changed().(
207 &mut self,
208 pkgname: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
209 steps_done: u64,
210 total_steps: u64,
211 action: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
212 ) {
213 self.innerrust-analyzer cargo rust-apt 0.8.0 progress/InstallProgress#inner.
214 .status_changedrust-analyzer cargo rust-apt 0.8.0 progress/DynInstallProgress#status_changed().(pkgname, steps_done, total_steps, action)
215 }
216
217 fn errorrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`]error().(&mut self, pkgname: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, steps_done: u64, total_steps: u64, error: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) {
218 self.innerrust-analyzer cargo rust-apt 0.8.0 progress/InstallProgress#inner..errorrust-analyzer cargo rust-apt 0.8.0 progress/DynInstallProgress#error().(pkgname, steps_done, total_steps, error)
219 }
220
221 pub fn pinrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`]pin().(&mut self) -> Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut InstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/InstallProgress#<'a>> { Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`]new().(self) }
222 }
223
224 impl<'a> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for InstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/InstallProgress#<'a> {
225 fn defaultrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`][Default]default().() -> Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`][Default] { Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`][Default]::aptrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`]apt().() }
226 }
227
228 /// Impl for sending DynInstallProgress across the barrier.
229 unsafe impl<'a> ExternTyperust-analyzer cargo cxx 1.0.199 extern_type/ExternType# for InstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/InstallProgress#<'a> {
230 type Idrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`][ExternType]Id# = cxxrust-analyzer cargo cxx 1.0.199 crate/::type_idrust-analyzer cargo cxx 1.0.199 type_id/type_id!!("InstallProgress");
231 type Kindrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`][ExternType]Kind# = cxxrust-analyzer cargo cxx 1.0.199 crate/::kindrust-analyzer cargo cxx 1.0.199 extern_type/kind/::Trivialrust-analyzer cargo cxx 1.0.199 extern_type/kind/Trivial#;
232 }
233
234 /// Internal struct to pass into [`crate::Cache::resolve`]. The C++ library for
235 /// this wants a progress parameter for this, but it doesn't appear to be doing
236 /// anything. Furthermore, [the Python-APT implementation doesn't accept a
237 /// parameter for their dependency resolution functionality](https://apt-team.pages.debian.net/python-apt/library/apt_pkg.html#apt_pkg.ProblemResolver.resolve),
238 /// so we should be safe to remove it here.
239 struct NoOpProgressrust-analyzer cargo rust-apt 0.8.0 progress/NoOpProgress# {}
240
241 impl DynOperationProgressrust-analyzer cargo rust-apt 0.8.0 progress/DynOperationProgress# for NoOpProgressrust-analyzer cargo rust-apt 0.8.0 progress/NoOpProgress# {
242 fn updaterust-analyzer cargo rust-apt 0.8.0 progress/impl#[NoOpProgress][DynOperationProgress]update().(&mut self, _operation: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, _percent: f32) {}
243
244 fn donerust-analyzer cargo rust-apt 0.8.0 progress/impl#[NoOpProgress][DynOperationProgress]done().(&mut self) {}
245 }
246
247 /// AptAcquireProgress is the default struct for the update method on the cache.
248 ///
249 /// This struct mimics the output of `apt update`.
250 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
251 pub struct AptAcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress# {
252 lastlinerust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#lastline.: usize,
253 pulse_intervalrust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#pulse_interval.: usize,
254 disablerust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#disable.: bool,
255 configrust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#config.: Configrust-analyzer cargo rust-apt 0.8.0 config/Config#,
256 }
257
258 impl AptAcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress# {
259 /// Returns a new default progress instance.
260 pub fn newrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress]new().() -> Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress] { Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress]::defaultrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress][Default]default().() }
261
262 /// Returns a disabled progress instance. No output will be shown.
263 pub fn disablerust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress]disable().() -> Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress] {
264 AptAcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress# {
265 disablerust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#disable.: true,
266 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress][Default]default().()
267 }
268 }
269
270 /// Helper function to clear the last line.
271 fn clear_last_linerust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress]clear_last_line().(&mut self, term_width: usize) {
272 if self.disablerust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#disable. {
273 return;
274 }
275
276 if self.lastlinerust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#lastline. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
277 return;
278 }
279
280 if self.lastlinerust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#lastline. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().term_width {
281 self.lastlinerust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#lastline. = term_width
282 }
283
284 printrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/print!!("\r{}", " ".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(self.lastlinerust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#lastline.));
285 printrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/print!!("\r");
286 stdoutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/stdout().().flushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/impl#[Stdout][Write]flush().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
287 }
288 }
289
290 impl DynAcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress# for AptAcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress# {
291 /// Used to send the pulse interval to the apt progress class.
292 ///
293 /// Pulse Interval is in microseconds.
294 ///
295 /// Example: 1 second = 1000000 microseconds.
296 ///
297 /// Apt default is 500000 microseconds or 0.5 seconds.
298 ///
299 /// The higher the number, the less frequent pulse updates will be.
300 ///
301 /// Pulse Interval set to 0 assumes the apt defaults.
302 fn pulse_intervalrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress][DynAcquireProgress]pulse_interval().(&self) -> usize { self.pulse_intervalrust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#pulse_interval. }
303
304 /// Called when an item is confirmed to be up-to-date.
305 ///
306 /// Prints out the short description and the expected size.
307 fn hitrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress][DynAcquireProgress]hit().(&mut self, item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#) {
308 if self.disablerust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#disable. {
309 return;
310 }
311
312 self.clear_last_linerust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress]clear_last_line().(terminal_widthrust-analyzer cargo rust-apt 0.8.0 util/terminal_width().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1);
313
314 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("\rHit:{} {}", item.ownerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]owner().().idrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]id().(), item.descriptionrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]description().());
315 }
316
317 /// Called when an Item has started to download
318 ///
319 /// Prints out the short description and the expected size.
320 fn fetchrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress][DynAcquireProgress]fetch().(&mut self, item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#) {
321 if self.disablerust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#disable. {
322 return;
323 }
324
325 self.clear_last_linerust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress]clear_last_line().(terminal_widthrust-analyzer cargo rust-apt 0.8.0 util/terminal_width().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1);
326
327 let mut string = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("\rGet:{} {}", item.ownerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]owner().().idrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]id().(), item.descriptionrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]description().());
328
329 let file_size = item.ownerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]owner().().file_sizerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]file_size().();
330 if file_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().0 {
331 string.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(" [{}]", unit_strrust-analyzer cargo rust-apt 0.8.0 util/unit_str().(file_size, NumSysrust-analyzer cargo rust-apt 0.8.0 util/NumSys#::Decimalrust-analyzer cargo rust-apt 0.8.0 util/NumSys#Decimal#)));
332 }
333
334 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{string}");
335 }
336
337 /// Called when an item is successfully and completely fetched.
338 ///
339 /// We don't print anything here to remain consistent with apt.
340 fn donerust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress][DynAcquireProgress]done().(&mut self, _item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#) {
341 // self.clear_last_line(terminal_width() - 1);
342
343 // println!("This is done!");
344 }
345
346 /// Called when progress has started.
347 ///
348 /// Start does not pass information into the method.
349 ///
350 /// We do not print anything here to remain consistent with apt.
351 /// lastline length is set to 0 to ensure consistency when progress begins.
352 fn startrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress][DynAcquireProgress]start().(&mut self) { self.lastlinerust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#lastline. = 0; }
353
354 /// Called when progress has finished.
355 ///
356 /// Stop does not pass information into the method.
357 ///
358 /// prints out the bytes downloaded and the overall average line speed.
359 fn stoprust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress][DynAcquireProgress]stop().(&mut self, owner: &AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#) {
360 if self.disablerust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#disable. {
361 return;
362 }
363
364 self.clear_last_linerust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress]clear_last_line().(terminal_widthrust-analyzer cargo rust-apt 0.8.0 util/terminal_width().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1);
365
366 if pending_errorrust-analyzer cargo rust-apt 0.8.0 error/raw/pending_error().() {
367 return;
368 }
369
370 if owner.fetched_bytesrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]fetched_bytes().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().0 {
371 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!(
372 "Fetched {} in {} ({}/s)",
373 unit_strrust-analyzer cargo rust-apt 0.8.0 util/unit_str().(owner.fetched_bytesrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]fetched_bytes().(), NumSysrust-analyzer cargo rust-apt 0.8.0 util/NumSys#::Decimalrust-analyzer cargo rust-apt 0.8.0 util/NumSys#Decimal#),
374 time_strrust-analyzer cargo rust-apt 0.8.0 util/time_str().(owner.elapsed_timerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]elapsed_time().()),
375 unit_strrust-analyzer cargo rust-apt 0.8.0 util/unit_str().(owner.current_cpsrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]current_cps().(), NumSysrust-analyzer cargo rust-apt 0.8.0 util/NumSys#::Decimalrust-analyzer cargo rust-apt 0.8.0 util/NumSys#Decimal#)
376 );
377 } else {
378 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Nothing to fetch.");
379 }
380 }
381
382 /// Called when an Item fails to download.
383 ///
384 /// Print out the ErrorText for the Item.
385 fn failrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress][DynAcquireProgress]fail().(&mut self, item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#) {
386 if self.disablerust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#disable. {
387 return;
388 }
389
390 self.clear_last_linerust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress]clear_last_line().(terminal_widthrust-analyzer cargo rust-apt 0.8.0 util/terminal_width().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1);
391
392 let mut show_error = true;
393 let error_text = item.ownerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]owner().().error_textrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]error_text().();
394 let desc = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{} {}", item.ownerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]owner().().idrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]id().(), item.descriptionrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]description().());
395
396 match item.ownerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]owner().().statusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]status().() {
397 ItemStaterust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemState#::StatIdlerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemState]StatIdle. | ItemStaterust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemState#::StatDonerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemState]StatDone. => {
398 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("\rIgn: {desc}");
399 let key = "Acquire::Progress::Ignore::ShowErrorText";
400 if error_text.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() || self.configrust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#config..boolrust-analyzer cargo rust-apt 0.8.0 config/impl#[Config]bool().(key, false) {
401 show_error = false;
402 }
403 },
404 _ => {
405 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("\rErr: {desc}");
406 },
407 }
408
409 if show_error {
410 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("\r{error_text}");
411 }
412 }
413
414 /// Called periodically to provide the overall progress information
415 ///
416 /// Draws the current progress.
417 /// Each line has an overall percent meter and a per active item status
418 /// meter along with an overall bandwidth and ETA indicator.
419 fn pulserust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress][DynAcquireProgress]pulse().(&mut self, status: &AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#, owner: &PkgAcquirerust-analyzer cargo rust-apt 0.8.0 acquire/raw/PkgAcquire#) {
420 if self.disablerust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#disable. {
421 return;
422 }
423
424 // Minus 1 for the cursor
425 let term_width = terminal_widthrust-analyzer cargo rust-apt 0.8.0 util/terminal_width().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1;
426
427 let mut string = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
428 let mut percent_str = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("\r{:.0}%", status.percentrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]percent().());
429 let mut eta_str = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
430
431 // Set the ETA string if there is a rate of download
432 let current_cps = status.current_cpsrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]current_cps().();
433 if current_cps rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().0 {
434 let _ = writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(
435 eta_str,
436 " {} {}",
437 // Current rate of download
438 unit_strrust-analyzer cargo rust-apt 0.8.0 util/unit_str().(current_cps, NumSysrust-analyzer cargo rust-apt 0.8.0 util/NumSys#::Decimalrust-analyzer cargo rust-apt 0.8.0 util/NumSys#Decimal#),
439 // ETA String
440 time_strrust-analyzer cargo rust-apt 0.8.0 util/time_str().((status.total_bytesrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]total_bytes().() -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Sub<Self>`]sub(). status.current_bytesrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]current_bytes().()) /rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Div<Self>`]div(). current_cps)
441 );
442 }
443
444 for worker in owner.workersrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[PkgAcquire]workers().().iterrust-analyzer cargo cxx 1.0.199 cxx_vector/impl#[`CxxVector<T>`]iter().() {
445 let mut work_string = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
446 work_string.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(" [");
447
448 let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(item) = worker.itemrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqWorker]item().() else {
449 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().worker.statusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqWorker]status().().is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() {
450 work_string.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&worker.statusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqWorker]status().());
451 work_string.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(']');
452 }
453 continue;
454 };
455
456 let id = item.ownerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]owner().().idrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]id().();
457 if id rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().0 {
458 let _ = writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(work_string, " {id} ");
459 }
460 work_string.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&item.short_descrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]short_desc().());
461
462 let sub = item.ownerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]owner().().active_subprocessrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]active_subprocess().();
463 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().sub.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() {
464 work_string.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(' ');
465 work_string.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&sub);
466 }
467
468 work_string.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(' ');
469 work_string.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&unit_strrust-analyzer cargo rust-apt 0.8.0 util/unit_str().(worker.current_sizerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqWorker]current_size().(), NumSysrust-analyzer cargo rust-apt 0.8.0 util/NumSys#::Decimalrust-analyzer cargo rust-apt 0.8.0 util/NumSys#Decimal#));
470
471 if worker.total_sizerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqWorker]total_size().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().0 && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().item.ownerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]owner().().completerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]complete().() {
472 let _ = writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(
473 work_string,
474 "/{} {}%",
475 unit_strrust-analyzer cargo rust-apt 0.8.0 util/unit_str().(worker.total_sizerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqWorker]total_size().(), NumSysrust-analyzer cargo rust-apt 0.8.0 util/NumSys#::Decimalrust-analyzer cargo rust-apt 0.8.0 util/NumSys#Decimal#),
476 (worker.current_sizerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqWorker]current_size().() *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 100) /rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Div<Self>`]div(). worker.total_sizerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqWorker]total_size().()
477 );
478 }
479
480 work_string.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(']');
481
482 if (string.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().work_string.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().percent_str.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().eta_str.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().()) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().term_width {
483 break;
484 }
485
486 string.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&work_string);
487 }
488
489 // Display at least something if there is no worker strings
490 if string.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() {
491 string = " [Working]".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
492 }
493
494 // Push the worker strings on the percent string
495 percent_str.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&string);
496
497 // Fill the remaining space in the terminal if eta exists
498 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().eta_str.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() {
499 let fill_size = percent_str.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().eta_str.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().();
500 if fill_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().term_width {
501 percent_str.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&" ".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(term_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().fill_size))
502 }
503 }
504
505 // Push the final eta to the end of the filled string
506 percent_str.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&eta_str);
507
508 // Print and flush stdout
509 printrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/print!!("{percent_str}");
510 stdoutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/stdout().().flushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/impl#[Stdout][Write]flush().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
511
512 if self.lastlinerust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#lastline. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().percent_str.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() {
513 self.clear_last_linerust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptAcquireProgress]clear_last_line().(term_width);
514 }
515
516 self.lastlinerust-analyzer cargo rust-apt 0.8.0 progress/AptAcquireProgress#lastline. = percent_str.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().();
517 }
518 }
519
520 /// Default struct to handle the output of a transaction.
521 pub struct AptInstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/AptInstallProgress# {
522 configrust-analyzer cargo rust-apt 0.8.0 progress/AptInstallProgress#config.: Configrust-analyzer cargo rust-apt 0.8.0 config/Config#,
523 }
524
525 impl AptInstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/AptInstallProgress# {
526 pub fn newrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptInstallProgress]new().() -> Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptInstallProgress] {
527 Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptInstallProgress] {
528 configrust-analyzer cargo rust-apt 0.8.0 progress/AptInstallProgress#config.: Configrust-analyzer cargo rust-apt 0.8.0 config/Config#::newrust-analyzer cargo rust-apt 0.8.0 config/impl#[Config]new().(),
529 }
530 }
531 }
532
533 impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for AptInstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/AptInstallProgress# {
534 fn defaultrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptInstallProgress][Default]default().() -> Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptInstallProgress][Default] { Selfrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptInstallProgress][Default]::newrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptInstallProgress]new().() }
535 }
536
537 impl DynInstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/DynInstallProgress# for AptInstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/AptInstallProgress# {
538 fn status_changedrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptInstallProgress][DynInstallProgress]status_changed().(
539 &mut self,
540 _pkgname: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
541 steps_done: u64,
542 total_steps: u64,
543 _action: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
544 ) {
545 // Get the terminal's width and height.
546 let term_height = terminal_heightrust-analyzer cargo rust-apt 0.8.0 util/terminal_height().();
547 let term_width = terminal_widthrust-analyzer cargo rust-apt 0.8.0 util/terminal_width().();
548
549 // Save the current cursor position.
550 printrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/print!!("\x1b7");
551
552 // Go to the progress reporting line.
553 printrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/print!!("\x1b[{term_height};0f");
554 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::stdoutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/stdout().().flushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/impl#[Stdout][Write]flush().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
555
556 // Convert the float to a percentage string.
557 let percent = steps_done as f32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().total_steps as f32;
558 let mut percent_str = (percent rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().100.0).roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]round().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
559
560 let percent_padding = match percent_str.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() {
561 1 => " ",
562 2 => " ",
563 3 => "",
564 _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(),
565 };
566
567 percent_str = percent_padding.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&percent_str;
568
569 // Get colors for progress reporting.
570 // NOTE: The APT implementation confusingly has 'Progress-fg' for 'bg_color',
571 // and the same the other way around.
572 let bg_color = self
573 .configrust-analyzer cargo rust-apt 0.8.0 progress/AptInstallProgress#config.
574 .findrust-analyzer cargo rust-apt 0.8.0 config/impl#[Config]find().("Dpkg::Progress-Fancy::Progress-fg", "\x1b[42m");
575 let fg_color = self
576 .configrust-analyzer cargo rust-apt 0.8.0 progress/AptInstallProgress#config.
577 .findrust-analyzer cargo rust-apt 0.8.0 config/impl#[Config]find().("Dpkg::Progress-Fancy::Progress-bg", "\x1b[30m");
578 const BG_COLOR_RESETrust-analyzer cargo rust-apt 0.8.0 progress/BG_COLOR_RESET.: &str = "\x1b[49m";
579 const FG_COLOR_RESETrust-analyzer cargo rust-apt 0.8.0 progress/FG_COLOR_RESET.: &str = "\x1b[39m";
580
581 printrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/print!!("{bg_color}{fg_color}Progress: [{percent_str}%]{BG_COLOR_RESET}{FG_COLOR_RESET} ");
582
583 // The length of "Progress: [100%] ".
584 const PROGRESS_STR_LENrust-analyzer cargo rust-apt 0.8.0 progress/PROGRESS_STR_LEN.: usize = 17;
585
586 // Print the progress bar.
587 // We should safely be able to convert the `usize`.try_into() into the `u32`
588 // needed by `get_apt_progress_string`, as usize ints only take up 8 bytes on a
589 // 64-bit processor.
590 printrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/print!!(
591 "{}",
592 get_apt_progress_stringrust-analyzer cargo rust-apt 0.8.0 util/get_apt_progress_string().(percent, (term_width -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). PROGRESS_STR_LENrust-analyzer cargo rust-apt 0.8.0 progress/PROGRESS_STR_LEN.).try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())
593 );
594 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::stdoutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/stdout().().flushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/impl#[Stdout][Write]flush().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
595
596 // If this is the last change, remove the progress reporting bar.
597 // if steps_done == total_steps {
598 // print!("{}", " ".repeat(term_width));
599 // print!("\x1b[0;{}r", term_height);
600 // }
601 // Finally, go back to the previous cursor position.
602 printrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/print!!("\x1b8");
603 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::stdoutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/stdout().().flushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/impl#[Stdout][Write]flush().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
604 }
605
606 // TODO: Need to figure out when to use this.
607 fn errorrust-analyzer cargo rust-apt 0.8.0 progress/impl#[AptInstallProgress][DynInstallProgress]error().(&mut self, _pkgname: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, _steps_done: u64, _total_steps: u64, _error: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) {}
608 }
609
610 #[cxxrust-analyzer cargo cxx 1.0.199 crate/::bridgerust-analyzer cargo cxxbridge-macro 1.0.199 bridge:]
611 pub(craterust-analyzer cargo rust-apt 0.8.0 crate/) mod rawrust-analyzer cargo rust-apt 0.8.0 progress/raw/ {
612 extern "Rust" {
613 type AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#<'a>;
614 type OperationProgressrust-analyzer cargo rust-apt 0.8.0 progress/OperationProgress#<'a>;
615 type InstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/InstallProgress#<'a>;
616
617 /// Called when an operation has been updated.
618 fn updaterust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`]update().(self: &mut OperationProgressrust-analyzer cargo rust-apt 0.8.0 progress/OperationProgress#, operation: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, percent: f32);
619
620 /// Called when an operation has finished.
621 fn donerust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`]done().(self: &mut OperationProgressrust-analyzer cargo rust-apt 0.8.0 progress/OperationProgress#);
622
623 /// Called when the install status has changed.
624 fn status_changedrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`]status_changed().(
625 self: &mut InstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/InstallProgress#,
626 pkgname: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
627 steps_done: u64,
628 total_steps: u64,
629 action: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
630 );
631
632 // TODO: What kind of errors can be returned here?
633 // Research and update higher level structs as well
634 // TODO: Create custom errors when we have better information
635 fn errorrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`]error().(
636 self: &mut InstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/InstallProgress#,
637 pkgname: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
638 steps_done: u64,
639 total_steps: u64,
640 error: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
641 );
642
643 /// Called on c++ to set the pulse interval.
644 fn pulse_intervalrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]pulse_interval().(self: &mut AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#) -> usize;
645
646 /// Called when an item is confirmed to be up-to-date.
647 fn hitrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]hit().(self: &mut AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#, item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 progress/raw/ItemDesc#);
648
649 /// Called when an Item has started to download
650 fn fetchrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]fetch().(self: &mut AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#, item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 progress/raw/ItemDesc#);
651
652 /// Called when an Item fails to download
653 fn failrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]fail().(self: &mut AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#, item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 progress/raw/ItemDesc#);
654
655 /// Called periodically to provide the overall progress information
656 fn pulserust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]pulse().(self: &mut AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#, owner: &PkgAcquirerust-analyzer cargo rust-apt 0.8.0 progress/raw/PkgAcquire#);
657
658 /// Called when an item is successfully and completely fetched.
659 fn donerust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]done().(self: &mut AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#, item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 progress/raw/ItemDesc#);
660
661 /// Called when progress has started
662 fn startrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]start().(self: &mut AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#);
663
664 /// Called when progress has finished
665 fn stoprust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]stop().(self: &mut AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#);
666 }
667
668 extern "C++" {
669 type ItemDescrust-analyzer cargo rust-apt 0.8.0 progress/raw/ItemDesc# = craterust-analyzer cargo rust-apt 0.8.0 crate/::acquirerust-analyzer cargo rust-apt 0.8.0 acquire/::rawrust-analyzer cargo rust-apt 0.8.0 acquire/raw/::ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#;
670 type PkgAcquirerust-analyzer cargo rust-apt 0.8.0 progress/raw/PkgAcquire# = craterust-analyzer cargo rust-apt 0.8.0 crate/::acquirerust-analyzer cargo rust-apt 0.8.0 acquire/::rawrust-analyzer cargo rust-apt 0.8.0 acquire/raw/::PkgAcquirerust-analyzer cargo rust-apt 0.8.0 acquire/raw/PkgAcquire#;
671 includerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include!!("rust-apt/apt-pkg-c/types.h");
672 }
673 }