Skip to content

Commit 768ed53

Browse files
djcrami3l
authored andcommitted
Inline NotifyOnConsole
1 parent f1aaa1b commit 768ed53

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

src/cli/common.rs

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,26 @@ pub(crate) fn read_line() -> Result<String> {
124124
.context("unable to read from stdin for confirmation")
125125
}
126126

127-
#[derive(Default)]
128-
struct NotifyOnConsole {
127+
pub(super) struct Notifier {
128+
tracker: Arc<Mutex<DownloadTracker>>,
129129
ram_notice_shown: RefCell<bool>,
130130
verbose: bool,
131131
}
132132

133-
impl NotifyOnConsole {
134-
fn handle(&self, n: Notification<'_>) {
133+
impl Notifier {
134+
pub(super) fn new(verbose: bool, quiet: bool) -> Self {
135+
Self {
136+
tracker: DownloadTracker::new_with_display_progress(!quiet),
137+
ram_notice_shown: RefCell::new(false),
138+
verbose,
139+
}
140+
}
141+
142+
pub(super) fn handle(&self, n: Notification<'_>) {
143+
if self.tracker.lock().unwrap().handle_notification(&n) {
144+
return;
145+
}
146+
135147
if let Notification::Install(dist_notifications::Notification::Utils(
136148
util_notifications::Notification::SetDefaultBufferSize(_),
137149
)) = &n
@@ -167,30 +179,6 @@ impl NotifyOnConsole {
167179
}
168180
}
169181

170-
struct Notifier {
171-
tracker: Arc<Mutex<DownloadTracker>>,
172-
notifier: NotifyOnConsole,
173-
}
174-
175-
impl Notifier {
176-
fn new(verbose: bool, quiet: bool) -> Self {
177-
Self {
178-
tracker: DownloadTracker::new_with_display_progress(!quiet),
179-
notifier: NotifyOnConsole {
180-
verbose,
181-
..Default::default()
182-
},
183-
}
184-
}
185-
186-
fn handle(&self, n: Notification<'_>) {
187-
if self.tracker.lock().unwrap().handle_notification(&n) {
188-
return;
189-
}
190-
self.notifier.handle(n);
191-
}
192-
}
193-
194182
#[cfg_attr(feature = "otel", tracing::instrument)]
195183
pub(crate) fn set_globals(current_dir: PathBuf, verbose: bool, quiet: bool) -> Result<Cfg> {
196184
let notifier = Notifier::new(verbose, quiet);

0 commit comments

Comments
 (0)