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 errors;
14pub mod retry;
15
16pub use client::{
17    map_api_error, NetworkConfigEntry, NetworkConfigResponse, TaskFastClient, UserProfile,
18};
19pub use errors::{Error, Result};
20pub use retry::{with_backoff, RetryPolicy};
21
22/// Re-exported so downstream crates can call the generated client's
23/// `baseurl()` / `client()` accessors — progenitor 0.11+ moved them off the
24/// inherent impl into this trait, which must be in scope at the call site.
25pub use progenitor_client::ClientInfo;
26
27/// Convert an `i64` page limit (as parsed from the CLI) into the
28/// `Option<NonZeroU64>` the generated client now requires: progenitor 0.14 /
29/// typify encodes the spec's `minimum: 1` in the type. Non-positive limits
30/// map to `None`, letting the server apply its default page size.
31pub fn page_limit(n: i64) -> Option<std::num::NonZeroU64> {
32    u64::try_from(n).ok().and_then(std::num::NonZeroU64::new)
33}
34
35/// Generated typed client + DTOs for the TaskFast OpenAPI spec.
36///
37/// Produced by `progenitor` from `spec/openapi.yaml` at build time; see
38/// `build.rs` and `xtask::normalize_spec`. Do not edit by hand — regenerate
39/// by changing the spec.
40#[allow(
41    clippy::all,
42    clippy::pedantic,
43    dead_code,
44    irrefutable_let_patterns,
45    missing_docs,
46    non_camel_case_types,
47    non_snake_case,
48    renamed_and_removed_lints,
49    unknown_lints,
50    rustdoc::broken_intra_doc_links,
51    rustdoc::invalid_html_tags
52)]
53pub mod api {
54    include!(concat!(env!("OUT_DIR"), "/codegen.rs"));
55}