asimov_patterns/programs/
indexer.rs

1// This is free and unencumbered software released into the public domain.
2
3use crate::Execute;
4use alloc::{string::String, vec::Vec};
5use bon::Builder;
6
7/// RDF dataset indexer. Consumes RDF input, maintains a persistent index.
8///
9/// See: https://asimov-specs.github.io/program-patterns/#indexer
10pub trait Indexer<E>: Execute<(), E> {}
11
12/// Configuration options for [`Indexer`].
13///
14/// # Examples
15///
16/// ```rust
17/// use asimov_patterns::IndexerOptions;
18///
19/// let options = IndexerOptions::builder()
20///     .input("jsonld")
21///     .build();
22/// ```
23#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, Builder)]
24#[builder(derive(Debug), on(String, into))]
25pub struct IndexerOptions {
26    /// Extended nonstandard indexer options.
27    #[builder(field)]
28    pub other: Vec<String>,
29
30    /// The input format.
31    pub input: Option<String>,
32}
33
34impl<S: indexer_options_builder::State> IndexerOptionsBuilder<S> {
35    pub fn other(mut self, flag: impl Into<String>) -> Self {
36        self.other.push(flag.into());
37        self
38    }
39
40    pub fn maybe_other(mut self, flag: Option<impl Into<String>>) -> Self {
41        if let Some(flag) = flag {
42            self.other.push(flag.into());
43        }
44        self
45    }
46}