pub struct ListerOptions<T: Clone = String, F = String> {
pub other: Vec<String>,
pub sort: Option<SortKeys<T>>,
pub before: Option<String>,
pub after: Option<String>,
pub offset: Option<usize>,
pub limit: Option<usize>,
pub output: Option<OutputFormat<F>>,
}Expand description
Output-format and pagination requests for a Lister.
T is the sort-key type in SortKeys<T>; F is the custom-format type in
OutputFormat<F>. Both default to String. Enum keys only need
Clone for storage. Clap parsing requires both types to be
Clone + Send + Sync + 'static and implement core::str::FromStr, with
parse errors implementing core::fmt::Display. These parsing bounds do
not constrain programmatically constructed options. Parsing uses the
sort-key grammar from SortKeys.
Default leaves all optional fields unset and other empty: no caller
limit, no skipped entries or cursor bounds, and the program’s default order
and output format. The collection URL is supplied separately by the runner.
Clap parsing uses the CLI’s offset default of Some(0), whereas Default
and the builder leave it unset. A host can flatten crate::CachingOptions,
crate::FilteringOptions, and crate::TimingOptions alongside this type
for shared caching, output filtering, and execution timing arguments.
The other, before, and after fields are programmatic-only.
These fields express requested behavior, not program capabilities; supply
known native support separately using ListerCapabilities.
Sorting and all pagination options have explicit native capabilities, and
the portable sort-expression grammar is still unresolved. Use only keys
and syntax supported by the selected program’s profile. Concrete hosts must
distinguish native support from emulation; see crate::programs for links
to the runner’s currently implemented behavior.
§Examples
use asimov_patterns::ListerOptions;
let options: ListerOptions = ListerOptions::builder()
.offset(20)
.limit(100)
.output("jsonl")
.build();
let cursor_page: ListerOptions = ListerOptions::builder()
.after("urn:example:entry:123")
.limit(25)
.build();
assert_eq!(cursor_page.after.as_deref(), Some("urn:example:entry:123"));
assert!(cursor_page.offset.is_none());use asimov_patterns::{ListerOptions, OutputFormat};
use clientele::options::sort::{SortKey, SortKeys};
#[derive(Clone)]
enum MyProps { FirstName, LastName }
let options = ListerOptions::<MyProps>::builder()
.sort(SortKeys::new(&[
SortKey::new(MyProps::LastName, false),
SortKey::new(MyProps::FirstName, false),
]))
.output(OutputFormat::Jsonl)
.build();Fields§
§other: Vec<String>Additional arguments placed after generated options and before the URL.
Each string is one literal argument, without shell expansion. The runner
supplies the URL separately; do not duplicate it here. See crate::programs.
sort: Option<SortKeys<T>>Sort resources by the specified keys. (Prefix a key with - for descending order.)
Ordering request passed as --sort=SORT. The default string-keyed
SortKeys implements display; typed keys retain their enum values.
SortKeys uses a - prefix for descending keys. This is the SDK’s
representation, not a universally supported PPS grammar; the program
must support both the option and the resulting expression. None omits
the request and uses the program’s documented default order.
before: Option<String>Exclusive upper cursor bound, passed as --before=URI.
The URI identifies an entry by its JSON-LD @id; it is an absolute URI
string, not a JSON object or an opaque encoded cursor. Select entries
before that entry in the chosen sort order. May be combined with after
to bound an interval, but not with numeric offset. None omits the bound.
The options value stores this string without validation or normalization.
after: Option<String>Exclusive lower cursor bound, passed as --after=URI.
The URI identifies an entry by its JSON-LD @id. Select entries after
that entry in the chosen sort order. May be combined with before, but
not with numeric offset. None omits the bound. As with before, the
options value stores the absolute URI string without validating it.
offset: Option<usize>The index offset of the first output.
Number of entries to skip, passed as --offset=INDEX.
None omits the option (default 0); Some(0) explicitly skips none.
Offset is applied after sorting and before the limit. Programs may omit
native support. Do not combine an offset, even Some(0), with before
or after; these are alternative pagination modes.
limit: Option<usize>The maximum count of outputs [default: none].
Requested listing limit (--limit=COUNT, or -n, when forwarded natively).
None imposes no caller-requested limit; Some(0) requests no entries.
ListerCapabilities::limit describes native support. A host can enforce
the request even when the native flag is unsupported, and independently
cap output to protect against bugs in programs that do accept the flag.
The program contract counts complete entries, not RDF statements, lines,
or bytes; consult the runner’s listing behavior for its
additional line-based cap and zero-limit handling. This options value
does not validate entry boundaries.
output: Option<OutputFormat<F>>The output format.
Passed as --output=FORMAT (-o in the CLI). Standard choices are
OutputFormat::Jsonl and OutputFormat::Url; OutputFormat::Other
stores an application-defined format.
None omits the option; the specified program default is jsonl.
The option selects a representation, not a file. Executors may support
only a subset of formats; JSONL graph pipelines require jsonl.
Implementations§
Source§impl<T: Clone, F> ListerOptions<T, F>
impl<T: Clone, F> ListerOptions<T, F>
Sourcepub fn builder() -> ListerOptionsBuilder<T, F>
pub fn builder() -> ListerOptionsBuilder<T, F>
Create an instance of ListerOptions using the builder syntax
Trait Implementations§
Source§impl<T, F> Args for ListerOptions<T, F>
Available on crate feature clap only.
impl<T, F> Args for ListerOptions<T, F>
clap only.Source§fn augment_args(command: Command) -> Command
fn augment_args(command: Command) -> Command
Source§fn augment_args_for_update(command: Command) -> Command
fn augment_args_for_update(command: Command) -> Command
Command so it can instantiate self via
FromArgMatches::update_from_arg_matches_mut Read moreSource§impl<T: Clone, F> Default for ListerOptions<T, F>
impl<T: Clone, F> Default for ListerOptions<T, F>
impl<T: Eq + Clone, F: Eq> Eq for ListerOptions<T, F>
Source§impl<T, F> FromArgMatches for ListerOptions<T, F>
Available on crate feature clap only.
impl<T, F> FromArgMatches for ListerOptions<T, F>
clap only.Source§fn from_arg_matches(matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(matches: &ArgMatches) -> Result<Self, Error>
Source§fn from_arg_matches_mut(matches: &mut ArgMatches) -> Result<Self, Error>
fn from_arg_matches_mut(matches: &mut ArgMatches) -> Result<Self, Error>
Source§fn update_from_arg_matches(&mut self, matches: &ArgMatches) -> Result<(), Error>
fn update_from_arg_matches(&mut self, matches: &ArgMatches) -> Result<(), Error>
ArgMatches to self.Source§fn update_from_arg_matches_mut(
&mut self,
matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut( &mut self, matches: &mut ArgMatches, ) -> Result<(), Error>
ArgMatches to self.