Skip to main content

taskfast_client/
lib.rs

1// SPDX-License-Identifier: MIT
2//! TaskFast typed HTTP client.
3//!
4//! The `api` module is generated from `spec/openapi.yaml` at build time by
5//! `build.rs`. The rewritten spec (error-alias folding) is produced in-memory
6//! via `xtask::normalize_spec` so the on-disk spec stays authoritative.
7//!
8//! Use [`api::Client`] to issue requests; cross-cutting concerns
9//! ([`errors::Error`], [`retry::with_backoff`]) live in sibling modules and
10//! will be composed over the generated client in a follow-up.
11
12pub mod client;
13pub mod corr;
14pub mod errors;
15pub mod retry;
16
17pub use client::{
18    map_api_error, NetworkConfigEntry, NetworkConfigResponse, TaskFastClient, UserProfile,
19};
20// `record_corr` is referenced by the generated client as `crate::record_corr`
21// (wired as progenitor's post-hook in build.rs), so it must live at the root.
22pub use corr::{record_corr, record_corr_response, take_last_corr};
23pub use errors::{Error, Result};
24pub use retry::{with_backoff, RetryPolicy};
25
26/// Re-exported so downstream crates can call the generated client's
27/// `baseurl()` / `client()` accessors — progenitor 0.11+ moved them off the
28/// inherent impl into this trait, which must be in scope at the call site.
29pub use progenitor_client::ClientInfo;
30
31/// Convert an `i64` page limit (as parsed from the CLI) into the
32/// `Option<NonZeroU64>` the generated client now requires: progenitor 0.14 /
33/// typify encodes the spec's `minimum: 1` in the type. Non-positive limits
34/// map to `None`, letting the server apply its default page size.
35pub fn page_limit(n: i64) -> Option<std::num::NonZeroU64> {
36    u64::try_from(n).ok().and_then(std::num::NonZeroU64::new)
37}
38
39/// Generated typed client + DTOs for the TaskFast OpenAPI spec.
40///
41/// Produced by `progenitor` from `spec/openapi.yaml` at build time; see
42/// `build.rs` and `xtask::normalize_spec`. Do not edit by hand — regenerate
43/// by changing the spec.
44#[allow(
45    clippy::all,
46    clippy::pedantic,
47    dead_code,
48    irrefutable_let_patterns,
49    missing_docs,
50    non_camel_case_types,
51    non_snake_case,
52    renamed_and_removed_lints,
53    unknown_lints,
54    rustdoc::broken_intra_doc_links,
55    rustdoc::invalid_html_tags
56)]
57pub mod api {
58    include!(concat!(env!("OUT_DIR"), "/codegen.rs"));
59}