summaryrefslogtreecommitdiff
path: root/src/genlist.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/genlist.rs')
-rw-r--r--src/genlist.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/genlist.rs b/src/genlist.rs
index a81a997..3a0d81a 100644
--- a/src/genlist.rs
+++ b/src/genlist.rs
@@ -1,27 +1,39 @@
+//! A list of generations on the server.
+
use crate::chunkid::ChunkId;
use crate::generation::{FinishedGeneration, GenId};
+/// A list of generations on the server.
pub struct GenerationList {
list: Vec<FinishedGeneration>,
}
+/// Possible errors from listing generations.
#[derive(Debug, thiserror::Error)]
pub enum GenerationListError {
+ /// Server doesn't know about a generation.
#[error("Unknown generation: {0}")]
UnknownGeneration(ChunkId),
}
impl GenerationList {
+ /// Create a new list of generations.
pub fn new(gens: Vec<FinishedGeneration>) -> Self {
let mut list = gens;
list.sort_by_cached_key(|gen| gen.ended().to_string());
Self { list }
}
+ /// Return an iterator over the generations.
pub fn iter(&self) -> impl Iterator<Item = &FinishedGeneration> {
self.list.iter()
}
+ /// Resolve a symbolic name of a generation into its identifier.
+ ///
+ /// For example, "latest" refers to the latest backup, but needs
+ /// to be resolved into an actual, immutable id to actually be
+ /// restored.
pub fn resolve(&self, genref: &str) -> Result<GenId, GenerationListError> {
let gen = if self.list.is_empty() {
None