asimov_patterns/lib.rs
1// This is free and unencumbered software released into the public domain.
2
3//! Execution traits and configuration values for ASIMOV program patterns.
4//!
5//! A *pattern* describes a program's role and logical input/output contract:
6//! for example, a [`Reader`] imports a document into RDF, an [`Adapter`] queries
7//! a dataset with SPARQL, and a [`Writer`] exports RDF to another representation.
8//! The [Program Patterns Specification][pps] defines their command-line
9//! interfaces and the requirements for hosts that invoke them.
10//!
11//! This crate provides two building blocks:
12//!
13//! - [`Execute<T>`] is the asynchronous operation shared by all pattern traits,
14//! with an implementation-specific associated [`Error`](Execute::Error) type.
15//! - [`programs`] contains role-specific marker traits and owned option values
16//! such as [`ReaderOptions`], with builders for configuring invocations.
17//! Optional native support is described separately by capability metadata such
18//! as [`ListerCapabilities`], using [`OptionSupport`] to distinguish unknown
19//! support from an explicit declaration. Callers supply this metadata; this
20//! crate does not discover capabilities or read module manifests.
21//!
22//! Executable lookup, process management, stream transport, and result decoding
23//! belong to implementations. The companion [`asimov-runner`][runner] crate
24//! supplies Tokio-backed process wrappers and re-exports these option types.
25//! [`asimov-remote`][remote] supplies HTTP-backed fetch/list operations using the
26//! same traits. Shared raw JSONL payloads live in [`asimov-flow`][flow]; each
27//! executor chooses its own error type. These role traits are the execution
28//! boundary for reusable components, while explicit typed port schemas and
29//! generalized graph scheduling are still evolving.
30//! Consult its documentation for supported output modes and current limitations;
31//! implementing a marker trait does not by itself establish PPS conformance.
32//!
33//! # Configuring an operation
34//!
35//! ```
36//! use asimov_patterns::ListerOptions;
37//!
38//! let options = ListerOptions::builder()
39//! .limit(25)
40//! .output("jsonl")
41//! .build();
42//!
43//! assert_eq!(options.limit, Some(25));
44//! assert_eq!(options.output.as_deref(), Some("jsonl"));
45//! assert!(options.other.is_empty());
46//! ```
47//!
48//! Building options neither executes a program nor validates its capabilities.
49//! Unset fields remain `None`: `asimov-runner` omits the corresponding flags and
50//! lets the program apply its specified defaults. In particular, `input` and
51//! `output` fields name **formats**, not files or stream endpoints.
52//!
53//! # Payloads and representations
54//!
55//! Pattern traits describe semantics without fixing a Rust representation for
56//! the result. Their type parameter `T` can represent serialized bytes, parsed
57//! data, a fallible stream, or another documented result representation; it is
58//! not the number of RDF statements or logical results. [`Indexer`] fixes its result to `()`
59//! because indexing has no payload output.
60//! A streaming implementation can return successful startup before execution
61//! finishes; its result must expose subsequent failures. See [`programs`] for
62//! links to concrete transport, completion, and result semantics.
63//!
64//! The options do not parse, validate, or transcode RDF. The spec's default
65//! `jsonl` token requires a shared [RDF mapping profile][rdf-mapping]; it does
66//! not imply JSON-LD or a particular JSON object shape. Composing two graph
67//! patterns requires agreement on both serialization and profile.
68//!
69//! # Features
70//!
71//! The crate declares `no_std` and uses `alloc` for strings, collections, and
72//! boxed futures. None of its public APIs is gated on the `std` feature.
73//! The default features are `all` and `std`; `std` enables standard-library
74//! support in dependencies. `all`, `tracing`, and `unstable` currently enable no
75//! additional behavior in this crate. Disabling `std` here does not guarantee
76//! that the dependency graph is usable on a target without a standard library.
77//! Currently, a standalone `--no-default-features` build fails in the transitive
78//! `dogma` dependency because collection traits are enabled without its `alloc`
79//! feature; the ungated API should not be read as a working no-std build guarantee.
80//!
81//! [pps]: https://asimov-specs.github.io/program-patterns/
82//! [runner]: https://docs.rs/asimov-runner
83//! [remote]: https://docs.rs/asimov-remote
84//! [flow]: https://docs.rs/asimov-flow
85//! [rdf-mapping]: https://asimov-specs.github.io/program-patterns/#rdf-mapping
86
87#![no_std]
88#![forbid(unsafe_code)]
89#![cfg_attr(docsrs, feature(doc_cfg))]
90
91extern crate alloc;
92
93#[cfg(feature = "std")]
94extern crate std;
95
96pub mod execute;
97pub use execute::*;
98
99pub mod capabilities;
100pub use capabilities::*;
101
102pub mod programs;
103pub use programs::*;