dirmgr: DirBootstrapStatus: Provide statuses and entries_mut
We're going to use these in a moment. One returns entries and the other statuses simply because that's what's actually going to be wanted.
This commit is contained in:
parent
5c51d03efb
commit
24d43f83fd
|
@ -18,6 +18,7 @@ use std::{
|
|||
|
||||
use educe::Educe;
|
||||
use futures::{stream::Stream, Future, StreamExt};
|
||||
use itertools::chain;
|
||||
use time::OffsetDateTime;
|
||||
use tor_basic_utils::skip_fmt;
|
||||
use tor_netdir::DirEvent;
|
||||
|
@ -457,9 +458,6 @@ impl DirBootstrapStatus {
|
|||
}
|
||||
|
||||
/// Return the next DirStatus, if there is one.
|
||||
///
|
||||
/// Testing-only.
|
||||
#[cfg(test)]
|
||||
fn next(&self) -> Option<&DirStatus> {
|
||||
match &self.0 {
|
||||
StatusEnum::Replacing { next, .. } => Some(&next.status),
|
||||
|
@ -467,6 +465,23 @@ impl DirBootstrapStatus {
|
|||
}
|
||||
}
|
||||
|
||||
/// Return the contained `DirStatus`es, in order: `current`, then `next`
|
||||
#[allow(dead_code)]
|
||||
fn statuses(&self) -> impl Iterator<Item = &DirStatus> + DoubleEndedIterator {
|
||||
chain!(self.current(), self.next(),)
|
||||
}
|
||||
|
||||
/// Return the contained `StatusEntry`s mutably, in order: `current`, then `next`
|
||||
#[allow(dead_code)]
|
||||
fn entries_mut(&mut self) -> impl Iterator<Item = &mut StatusEntry> + DoubleEndedIterator {
|
||||
let (current, next) = match &mut self.0 {
|
||||
StatusEnum::NoActivity => (None, None),
|
||||
StatusEnum::Single { current } => (Some(current), None),
|
||||
StatusEnum::Replacing { current, next } => (Some(current), Some(next)),
|
||||
};
|
||||
chain!(current, next,)
|
||||
}
|
||||
|
||||
/// Return the fraction of completion for directory download, in a form
|
||||
/// suitable for a progress bar at some particular time.
|
||||
///
|
||||
|
|
Loading…
Reference in New Issue