use std::path::Path;
use crate::segment::id_tracker::disk_id_tracker::on_disk_format::i2e_path;
use crate::segment::id_tracker::immutable_id_tracker::mappings_path;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum IdTrackerFormat {
Mutable,
Immutable,
Disk,
}
impl IdTrackerFormat {
fn from_presence(is_appendable: bool, has_mappings: bool, has_disk: bool) -> Self {
if is_appendable {
Self::Mutable
} else if has_disk {
Self::Disk
} else if has_mappings {
Self::Immutable
} else {
Self::Mutable
}
}
pub fn detect_local(segment_path: &Path, is_appendable: bool) -> Self {
Self::from_presence(
is_appendable,
mappings_path(segment_path).is_file(),
i2e_path(segment_path).is_file(),
)
}
}