Skip to content

Commit 700a983

Browse files
committed
Rearrange numtracker
1 parent dc2cfb8 commit 700a983

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

src/numtracker.rs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,6 @@ pub struct NumTracker {
2727
bl_locks: HashMap<String, Mutex<PathBuf>>,
2828
}
2929

30-
/// Number tracker for a directory that may or may not exist
31-
pub enum DirectoryTracker<'nt, 'bl> {
32-
NoDirectory,
33-
GdaDirectory(GdaNumTracker<'nt, 'bl>),
34-
}
35-
36-
impl DirectoryTracker<'_, '_> {
37-
pub async fn prev(&self) -> Result<Option<u32>, Error> {
38-
match self {
39-
DirectoryTracker::NoDirectory => Ok(None),
40-
DirectoryTracker::GdaDirectory(gnt) => Some(gnt.latest_scan_number().await).transpose(),
41-
}
42-
}
43-
44-
pub async fn set(&self, num: u32) -> Result<(), Error> {
45-
match self {
46-
DirectoryTracker::NoDirectory => Ok(()),
47-
DirectoryTracker::GdaDirectory(gnt) => gnt.create_num_file(num).await,
48-
}
49-
}
50-
}
51-
5230
impl NumTracker {
5331
/// Build a numtracker than will provide locked access to subdirectories that exists and no-op
5432
/// trackers for beamlines that do not have subdirectories.
@@ -93,6 +71,28 @@ impl NumTracker {
9371
}
9472
}
9573

74+
/// Number tracker for a directory that may or may not exist
75+
pub enum DirectoryTracker<'nt, 'bl> {
76+
NoDirectory,
77+
GdaDirectory(GdaNumTracker<'nt, 'bl>),
78+
}
79+
80+
impl DirectoryTracker<'_, '_> {
81+
pub async fn prev(&self) -> Result<Option<u32>, Error> {
82+
match self {
83+
DirectoryTracker::NoDirectory => Ok(None),
84+
DirectoryTracker::GdaDirectory(gnt) => Some(gnt.latest_scan_number().await).transpose(),
85+
}
86+
}
87+
88+
pub async fn set(&self, num: u32) -> Result<(), Error> {
89+
match self {
90+
DirectoryTracker::NoDirectory => Ok(()),
91+
DirectoryTracker::GdaDirectory(gnt) => gnt.create_num_file(num).await,
92+
}
93+
}
94+
}
95+
9696
#[derive(Debug)]
9797
pub struct GdaNumTracker<'nt, 'bl> {
9898
ext: &'bl str,
@@ -163,4 +163,5 @@ impl Display for InvalidExtension {
163163
f.write_str("Extension is not valid")
164164
}
165165
}
166+
166167
impl std::error::Error for InvalidExtension {}

0 commit comments

Comments
 (0)