Skip to main content

ListerOptions

Struct ListerOptions 

Source
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>

Source

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>
where T: Clone + FromStr + Send + Sync + 'static, T::Err: Display, F: Clone + FromStr + Send + Sync + 'static, F::Err: Display,

Available on crate feature clap only.
Source§

fn group_id() -> Option<Id>

Report the ArgGroup::id for this set of arguments
Source§

fn augment_args(command: Command) -> Command

Append to Command so it can instantiate Self via FromArgMatches::from_arg_matches_mut Read more
Source§

fn augment_args_for_update(command: Command) -> Command

Append to Command so it can instantiate self via FromArgMatches::update_from_arg_matches_mut Read more
Source§

impl<T: Clone + Clone, F: Clone> Clone for ListerOptions<T, F>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Clone, F: Debug> Debug for ListerOptions<T, F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Clone, F> Default for ListerOptions<T, F>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, T: Clone, F> Deserialize<'de> for ListerOptions<T, F>
where SortKeys<T>: FromStr, <SortKeys<T> as FromStr>::Err: Display, F: FromStr, F::Err: Display,

Available on crate feature serde only.
Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: Eq + Clone, F: Eq> Eq for ListerOptions<T, F>

Source§

impl<T, F> FromArgMatches for ListerOptions<T, F>
where T: Clone + FromStr + Send + Sync + 'static, T::Err: Display, F: Clone + FromStr + Send + Sync + 'static, F::Err: Display,

Available on crate feature clap only.
Source§

fn from_arg_matches(matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn from_arg_matches_mut(matches: &mut ArgMatches) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn update_from_arg_matches(&mut self, matches: &ArgMatches) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

fn update_from_arg_matches_mut( &mut self, matches: &mut ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

impl<T: Hash + Clone, F: Hash> Hash for ListerOptions<T, F>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: PartialEq + Clone, F: PartialEq> PartialEq for ListerOptions<T, F>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T: Clone, F> Serialize for ListerOptions<T, F>
where SortKeys<T>: Display, F: Display,

Available on crate feature serde only.
Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: PartialEq + Clone, F: PartialEq> StructuralPartialEq for ListerOptions<T, F>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.