crate::ix!();
pub trait FilePattern {
fn file_pattern(&self) -> Regex;
}
impl FilePattern for BatchIndex {
fn file_pattern(&self) -> Regex {
let index_pattern = match self {
BatchIndex::Usize(value) => format!("{}", value),
BatchIndex::Uuid(value) => format!("{}", value),
};
Regex::new(&format!(
r"^batch_(input|output|error|metadata)_{index_pattern}\.jsonl$",
index_pattern = index_pattern
))
.expect("Invalid regex pattern")
}
}
impl FilePattern for BatchIndexType {
fn file_pattern(&self) -> Regex {
let index_pattern = match self {
BatchIndexType::Usize => r"\d+",
BatchIndexType::Uuid => r"[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}",
};
Regex::new(&format!(
r"batch_(input|output|error|metadata)_{index_pattern}\.jsonl$",
index_pattern = index_pattern
)).expect("Invalid regex pattern")
}
}