asimov-patterns 25.2.0

ASIMOV Software Development Kit (SDK) for Rust
Documentation
// This is free and unencumbered software released into the public domain.

use crate::Execute;
use alloc::{string::String, vec::Vec};
use bon::Builder;

/// Graph iterator. Takes a URL input, produces RDF output.
///
/// See: https://asimov-specs.github.io/program-patterns/#cataloger
pub trait Cataloger<T, E>: Execute<T, E> {}

/// Configuration options for [`Cataloger`].
///
/// # Examples
///
/// ```rust
/// use asimov_patterns::CatalogerOptions;
///
/// let options = CatalogerOptions::builder()
///     .limit(100)
///     .output("jsonld")
///     .build();
/// ```
#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, Builder)]
#[builder(derive(Debug), on(String, into))]
pub struct CatalogerOptions {
    /// Extended nonstandard cataloger options.
    #[builder(field)]
    pub other: Vec<String>,

    /// The maximum number of outputs.
    pub limit: Option<usize>,

    /// The output format.
    pub output: Option<String>,
}

impl<S: cataloger_options_builder::State> CatalogerOptionsBuilder<S> {
    pub fn other(mut self, flag: impl Into<String>) -> Self {
        self.other.push(flag.into());
        self
    }

    pub fn maybe_other(mut self, flag: Option<impl Into<String>>) -> Self {
        if let Some(flag) = flag {
            self.other.push(flag.into());
        }
        self
    }
}