Introduce lifecycle-aware Layer::Empty variant and update callers

The `Layer` enum is transformed into a lifecycle-aware state machine with an `Empty` variant representing an unconstructed directory. Read and query operations now explicitly panic when invoked on this state, enforcing explicit progression through `create()` before use. Iterator methods are updated to handle the new variant exhaustively, and module visibility constants are adjusted to support the refactored structure.
This commit is contained in:
Eric Coissac
2026-08-20 20:41:48 +02:00
parent 1c54e60c9a
commit c4b69e1af5
4 changed files with 311 additions and 130 deletions
+4
View File
@@ -183,6 +183,7 @@ impl SiblingLayerExt for obilayeredmap::Layer {
match self {
obilayeredmap::Layer::Count(l) => l.iter_siblings(annex),
obilayeredmap::Layer::Presence(l) => l.iter_siblings(annex),
obilayeredmap::Layer::Empty { .. } => panic!("iter_siblings() called on an Empty layer"),
}
}
@@ -190,6 +191,7 @@ impl SiblingLayerExt for obilayeredmap::Layer {
match self {
obilayeredmap::Layer::Count(l) => l.iter_siblings_batch(annex, batch_size),
obilayeredmap::Layer::Presence(l) => l.iter_siblings_batch(annex, batch_size),
obilayeredmap::Layer::Empty { .. } => panic!("iter_siblings_batch() called on an Empty layer"),
}
}
@@ -197,6 +199,7 @@ impl SiblingLayerExt for obilayeredmap::Layer {
match self {
obilayeredmap::Layer::Count(l) => l.iter_minorants(annex),
obilayeredmap::Layer::Presence(l) => l.iter_minorants(annex),
obilayeredmap::Layer::Empty { .. } => panic!("iter_minorants() called on an Empty layer"),
}
}
@@ -204,6 +207,7 @@ impl SiblingLayerExt for obilayeredmap::Layer {
match self {
obilayeredmap::Layer::Count(l) => l.iter_minorants_batch(annex, batch_size),
obilayeredmap::Layer::Presence(l) => l.iter_minorants_batch(annex, batch_size),
obilayeredmap::Layer::Empty { .. } => panic!("iter_minorants_batch() called on an Empty layer"),
}
}
}