feat: add command pattern
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2024-05-12 14:29:14 +02:00
parent cf26422673
commit 5548d8e36e
10 changed files with 318 additions and 207 deletions

View File

@@ -5,10 +5,12 @@ use crate::shared_engine::SharedEngine;
mod local;
mod remote;
#[derive(Clone)]
enum QuerierVariant {
Local(local::Querier),
}
#[derive(Clone)]
pub struct Querier {
variant: QuerierVariant,
}
@@ -30,6 +32,16 @@ impl Querier {
}
}
pub async fn get_async(
&self,
root: &str,
path: impl IntoIterator<Item = impl Into<String>>,
) -> Option<GraphItem> {
match &self.variant {
QuerierVariant::Local(querier) => querier.get(root, path),
}
}
pub fn get_available_roots(&self) -> Option<Vec<String>> {
match &self.variant {
QuerierVariant::Local(querier) => querier.get_available_roots(),