pub trait LineProvider: Send + Sync + 'static {
fn get(&self, line_id: &str) -> Option<String>;
}
#[derive(Debug, Clone, Default)]
pub struct PassthroughProvider;
impl LineProvider for PassthroughProvider {
fn get(&self, _line_id: &str) -> Option<String> {
None
}
}
#[derive(Debug, Clone, Default)]
pub struct HashMapProvider {
map: std::collections::HashMap<String, String>,
}
impl HashMapProvider {
#[must_use]
pub fn new() -> Self {
Self::default()
}
pub fn insert(&mut self, id: impl Into<String>, text: impl Into<String>) {
self.map.insert(id.into(), text.into());
}
}
impl LineProvider for HashMapProvider {
fn get(&self, line_id: &str) -> Option<String> {
self.map.get(line_id).cloned()
}
}