use std::path::{Path, PathBuf};
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum MetadataFilter {
HasKey(String),
KeyValue { key: String, value: String },
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct BondQuery {
pub source: Option<PathBuf>,
pub target: Option<PathBuf>,
pub metadata: Option<MetadataFilter>,
}
impl BondQuery {
pub fn new() -> Self {
Self::default()
}
pub fn with_source<P: AsRef<Path>>(mut self, source: P) -> Self {
self.source = Some(source.as_ref().to_path_buf());
self
}
pub fn with_target<P: AsRef<Path>>(mut self, target: P) -> Self {
self.target = Some(target.as_ref().to_path_buf());
self
}
pub fn with_metadata_key(mut self, key: impl Into<String>) -> Self {
self.metadata = Some(MetadataFilter::HasKey(key.into()));
self
}
pub fn with_metadata(mut self, key: impl Into<String>, value: impl Into<String>) -> Self {
self.metadata = Some(MetadataFilter::KeyValue {
key: key.into(),
value: value.into(),
});
self
}
}