summaryrefslogtreecommitdiff
path: root/src/genlist.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-08-01 20:34:35 +0300
committerLars Wirzenius <liw@liw.fi>2021-08-01 20:55:04 +0300
commit2bc07b176bcf63f94bf6f1cca0ade2505958a15d (patch)
treee1dcf85cc76051baf44a63c1105ced26935109c2 /src/genlist.rs
parent0835677f33fe8fa89ee96e4c1b45e5711e10b461 (diff)
downloadobnam2-2bc07b176bcf63f94bf6f1cca0ade2505958a15d.tar.gz
refactor: add a type alias for generation ids
This will make it harder to accidentally use a string. Can still be confused with a chunk id. Sponsored-by: author
Diffstat (limited to 'src/genlist.rs')
-rw-r--r--src/genlist.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/genlist.rs b/src/genlist.rs
index 21f558c..edc405a 100644
--- a/src/genlist.rs
+++ b/src/genlist.rs
@@ -1,5 +1,5 @@
use crate::chunkid::ChunkId;
-use crate::generation::FinishedGeneration;
+use crate::generation::{FinishedGeneration, GenId};
pub struct GenerationList {
list: Vec<FinishedGeneration>,
@@ -22,7 +22,7 @@ impl GenerationList {
self.list.iter()
}
- pub fn resolve(&self, genref: &str) -> Result<String, GenerationListError> {
+ pub fn resolve(&self, genref: &str) -> Result<GenId, GenerationListError> {
let gen = if self.list.is_empty() {
None
} else if genref == "latest" {
@@ -45,7 +45,7 @@ impl GenerationList {
None => Err(GenerationListError::UnknownGeneration(ChunkId::recreate(
genref,
))),
- Some(gen) => Ok(gen.id().to_string()),
+ Some(gen) => Ok(gen.id()),
}
}
}