data_gov/lib.rs
1//! High-level bindings for the U.S. [data.gov](https://data.gov) CKAN portal.
2//!
3//! The `data-gov` crate bundles an ergonomic async client, CLI-friendly utilities,
4//! and configuration helpers on top of the lower-level [`data_gov_ckan`] crate. It
5//! is designed for read-only exploration workflows such as search, dataset
6//! inspection, and downloading published resources. The main entry point is
7//! [`DataGovClient`], which requires a Tokio runtime.
8
9/// Base URL for the public data.gov CKAN API (`/api/3`).
10///
11/// This constant is provided for convenience when you need to construct direct
12/// HTTP calls or configure the lower-level [`data_gov_ckan::Configuration`].
13pub const DATA_GOV_BASE_URL: &str = "https://catalog.data.gov/api/3";
14
15// Re-export the CKAN crate for direct access
16pub use data_gov_ckan as ckan;
17
18// Public modules
19pub mod client;
20pub mod colors;
21pub mod config;
22pub mod error;
23
24// Re-export main types for convenience
25pub use client::DataGovClient;
26pub use colors::{ColorHelper, ColorMode};
27pub use config::{DataGovConfig, OperatingMode};
28pub use error::{DataGovError, Result};
29
30// pub trait CKANResponse: serde::de::DeserializeOwned {}
31
32// // Extension trait for automatic conversion
33// pub trait IntoCKANResponse {
34// fn into_ckan<T>(self) -> T
35// where
36// T: CKANResponse;
37// }
38
39// impl IntoCKANResponse for serde_json::Value {
40// fn into_ckan<T>(self) -> T
41// where
42// T: CKANResponse,
43// {
44// serde_json::from_value::<T>(self)
45// .expect("Failed to convert Value to target struct")
46// }
47// }
48
49// #[derive(serde::Deserialize, Debug)]
50// pub struct PackageSearchResult {
51// pub help: String,
52// pub success: bool,
53// pub result: PackageSearchResultDetail,
54// }
55
56// impl CKANResponse for PackageSearchResult {}
57
58// #[derive(serde::Deserialize, Debug)]
59// pub struct PackageSearchResultDetail {
60// pub count: u32,
61// pub sort: Option<String>,
62// pub results: Vec<PackageSearchResultItem>,
63// // pub facets: Option<serde_json::Value>,
64// // pub search_facets: Option<serde_json::Value>,
65// }
66
67// #[derive(serde::Deserialize, Debug)]
68// pub struct PackageSearchResultItem {
69// pub display_name: Option<String>,
70// pub id: String,
71// pub name: String,
72// pub state: String,
73// pub vocabulary_id: Option<String>,
74// }
75
76// impl PackageSearchResultItem {
77
78// // Metadata contains resource URLs and more
79// pub fn to_metadata_url(&self) -> String {
80// format!("https://catalog.data.gov/harvest/object/{}", self.id)
81// }
82// }