Compare commits

...

10 commits
0.1.4 ... main

Author SHA1 Message Date
rzmk
0b8ffbf53c build: update dependencies 2026-05-12 17:14:44 -04:00
rzmk
83eb41510f docs: fix package_list description 2026-05-12 17:09:55 -04:00
rzmk
a88a8fffc3 chore: examples update and docs, add package-list example 2026-05-05 17:26:59 -04:00
rzmk
4ff1155d9b docs: add .env.example for disabling telemetry 2026-05-05 17:03:28 -04:00
rzmk
cd565bbda0 chore: update example to use latest version of ckanaction 2026-05-05 16:51:19 -04:00
rzmk
582cabbcf8 build: 0.2.0 2026-05-05 16:50:11 -04:00
rzmk
b98af97335 build: update dependencies 2026-05-05 16:49:25 -04:00
rzmk
e5d4f8d442 fix: update docs and errors with CKANError 2026-05-05 16:48:56 -04:00
rzmk
677475f750 fix: update error type to CKANError 2026-05-05 16:43:34 -04:00
rzmk
cb2ed8476b feat: use thiserror for error handling 2026-05-05 16:40:02 -04:00
17 changed files with 2526 additions and 604 deletions

99
Cargo.lock generated
View file

@ -65,9 +65,9 @@ checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33"
[[package]]
name = "cc"
version = "1.2.61"
version = "1.2.62"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d16d90359e986641506914ba71350897565610e87ce0ad9e6f28569db3dd5c6d"
checksum = "a1dce859f0832a7d088c4f1119888ab94ef4b5d6795d1ce05afb7fe159d79f98"
dependencies = [
"find-msvc-tools",
"shlex",
@ -81,12 +81,13 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
[[package]]
name = "ckanaction"
version = "0.1.4"
version = "0.2.0"
dependencies = [
"bon",
"reqwest",
"serde",
"serde_json",
"thiserror",
"tokio",
]
@ -320,9 +321,9 @@ dependencies = [
[[package]]
name = "h2"
version = "0.4.13"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f44da3a8150a6703ed5d34e164b875fd14c2cdab9af1252a9a1020bde2bdc54"
checksum = "171fefbc92fe4a4de27e0698d6a5b392d6a0e333506bc49133760b3bcf948733"
dependencies = [
"atomic-waker",
"bytes",
@ -348,9 +349,9 @@ dependencies = [
[[package]]
name = "hashbrown"
version = "0.17.0"
version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51"
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
[[package]]
name = "heck"
@ -596,7 +597,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"
dependencies = [
"equivalent",
"hashbrown 0.17.0",
"hashbrown 0.17.1",
"serde",
"serde_core",
]
@ -607,16 +608,6 @@ version = "2.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2"
[[package]]
name = "iri-string"
version = "0.7.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25e659a4bb38e810ebc252e53b5814ff908a8c58c2a9ce2fae1bbec24cbf4e20"
dependencies = [
"memchr",
"serde",
]
[[package]]
name = "itoa"
version = "1.0.18"
@ -625,9 +616,9 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
[[package]]
name = "js-sys"
version = "0.3.97"
version = "0.3.98"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1840c94c045fbcf8ba2812c95db44499f7c64910a912551aaaa541decebcacf"
checksum = "67df7112613f8bfd9150013a0314e196f4800d3201ae742489d999db2f979f08"
dependencies = [
"cfg-if",
"futures-util",
@ -732,15 +723,14 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "openssl"
version = "0.10.78"
version = "0.10.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f38c4372413cdaaf3cc79dd92d29d7d9f5ab09b51b10dded508fb90bb70b9222"
checksum = "bf0b434746ee2832f4f0baf10137e1cabb18cbe6912c69e2e33263c45250f542"
dependencies = [
"bitflags",
"cfg-if",
"foreign-types",
"libc",
"once_cell",
"openssl-macros",
"openssl-sys",
]
@ -764,9 +754,9 @@ checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe"
[[package]]
name = "openssl-sys"
version = "0.9.114"
version = "0.9.115"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13ce1245cd07fcc4cfdb438f7507b0c7e4f3849a69fd84d52374c66d83741bb6"
checksum = "158fe5b292746440aa6e7a7e690e55aeb72d41505e2804c23c6973ad0e9c9781"
dependencies = [
"cc",
"libc",
@ -1034,7 +1024,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
dependencies = [
"serde_core",
"serde_derive",
]
[[package]]
@ -1203,6 +1192,26 @@ dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "thiserror"
version = "2.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "2.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tinystr"
version = "0.8.3"
@ -1215,9 +1224,9 @@ dependencies = [
[[package]]
name = "tokio"
version = "1.52.1"
version = "1.52.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b67dee974fe86fd92cc45b7a95fdd2f99a36a6d7b0d431a231178d3d670bbcc6"
checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe"
dependencies = [
"bytes",
"libc",
@ -1291,20 +1300,20 @@ dependencies = [
[[package]]
name = "tower-http"
version = "0.6.8"
version = "0.6.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8"
checksum = "68d6fdd9f81c2819c9a8b0e0cd91660e7746a8e6ea2ba7c6b2b057985f6bcb51"
dependencies = [
"bitflags",
"bytes",
"futures-util",
"http",
"http-body",
"iri-string",
"pin-project-lite",
"tower",
"tower-layer",
"tower-service",
"url",
]
[[package]]
@ -1427,9 +1436,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen"
version = "0.2.120"
version = "0.2.121"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df52b6d9b87e0c74c9edfa1eb2d9bf85e5d63515474513aa50fa181b3c4f5db1"
checksum = "49ace1d07c165b0864824eee619580c4689389afa9dc9ed3a4c75040d82e6790"
dependencies = [
"cfg-if",
"once_cell",
@ -1440,9 +1449,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-futures"
version = "0.4.70"
version = "0.4.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af934872acec734c2d80e6617bbb5ff4f12b052dd8e6332b0817bce889516084"
checksum = "96492d0d3ffba25305a7dc88720d250b1401d7edca02cc3bcd50633b424673b8"
dependencies = [
"js-sys",
"wasm-bindgen",
@ -1450,9 +1459,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.120"
version = "0.2.121"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78b1041f495fb322e64aca85f5756b2172e35cd459376e67f2a6c9dffcedb103"
checksum = "8e68e6f4afd367a562002c05637acb8578ff2dea1943df76afb9e83d177c8578"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@ -1460,9 +1469,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.120"
version = "0.2.121"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9dcd0ff20416988a18ac686d4d4d0f6aae9ebf08a389ff5d29012b05af2a1b41"
checksum = "d95a9ec35c64b2a7cb35d3fead40c4238d0940c86d107136999567a4703259f2"
dependencies = [
"bumpalo",
"proc-macro2",
@ -1473,9 +1482,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.120"
version = "0.2.121"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49757b3c82ebf16c57d69365a142940b384176c24df52a087fb748e2085359ea"
checksum = "c4e0100b01e9f0d03189a92b96772a1fb998639d981193d7dbab487302513441"
dependencies = [
"unicode-ident",
]
@ -1529,9 +1538,9 @@ dependencies = [
[[package]]
name = "web-sys"
version = "0.3.97"
version = "0.3.98"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2eadbac71025cd7b0834f20d1fe8472e8495821b4e9801eb0a60bd1f19827602"
checksum = "4b572dff8bcf38bad0fa19729c89bb5748b2b9b1d8be70cf90df697e3a8f32aa"
dependencies = [
"js-sys",
"wasm-bindgen",
@ -1779,9 +1788,9 @@ dependencies = [
[[package]]
name = "zerofrom"
version = "0.1.7"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69faa1f2a1ea75661980b013019ed6687ed0e83d069bc1114e2cc74c6c04c4df"
checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272"
dependencies = [
"zerofrom-derive",
]

View file

@ -1,10 +1,10 @@
[package]
name = "ckanaction"
version = "0.1.4"
version = "0.2.0"
edition = "2024"
description = "Rust library crate featuring an API wrapper of the CKAN Action v3 API."
repository = "https://github.com/dathere/ckanaction"
homepage = "https://ckanaction.dathere.com"
repository = "https://github.com/dathere/ckanaction"
license = "Unlicense"
keywords = ["ckan"]
categories = ["api-bindings", "asynchronous"]
@ -15,6 +15,7 @@ bon = "3.9.1"
reqwest = { version = "0.12.28", features = ["json", "multipart", "stream"] }
serde = "1.0.228"
serde_json = "1.0.149"
thiserror = "2.0.18"
[dev-dependencies]
tokio = { version = "1.52.1", features = ["full"] }
tokio = { version = "1.52.3", features = ["full"] }

View file

@ -13,10 +13,11 @@ cargo add ckanaction
Run `/package_list` endpoint with a limit of 5 results per page and print the output:
```rust
use ckanaction::CKANError;
use dotenvy::dotenv;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
async fn main() -> Result<(), CKANError> {
// Load environment variables from .env file
dotenv()?;
@ -89,3 +90,12 @@ To run some of the tests in the `tests` directory, first replace the values for
```bash
cargo test
```
## Examples
You can run an example from the `examples` directory by first changing into the directory then running `cargo run`. For example:
```bash
cd examples/status-show
cargo run
```

2
docs/.env.example Normal file
View file

@ -0,0 +1,2 @@
NEXT_TELEMETRY_DISABLED=1
DO_NOT_TRACK=1

View file

@ -11,10 +11,11 @@ This means that instead of using generic request library crates such as `reqwest
For example the following code can be ran to send an HTTP POST request to the `/package_list` endpoint of a local CKAN instance's API by using the `ckanaction` crate:
```rust
use ckanaction::CKANError;
use dotenvy::dotenv;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
async fn main() -> Result<(), CKANError> {
// Load environment variables from .env file
dotenv()?;

View file

@ -7,11 +7,11 @@ _openapi:
structuredData:
headings: []
contents:
- content: This endpoint lists CKAN resources.
- content: Return a list of the name of the site's datasets (packages).
---
{/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */}
This endpoint lists CKAN resources.
Return a list of the name of the site's datasets (packages).
<APIPage document={"./lib/openapi.yml"} operations={[{"path":"package_list","method":"post"}]} />

View file

@ -30,7 +30,7 @@ paths:
post:
operationId: package_list
summary: package_list
description: This endpoint lists CKAN resources.
description: Return a list of the name of the site's datasets (packages).
requestBody:
required: false
content:
@ -48,10 +48,11 @@ paths:
- lang: rust
label: Rust SDK (ckanaction) example
source: |
use ckanaction::CKANError;
use dotenvy::dotenv;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
async fn main() -> Result<(), CKANError> {
// Load environment variables from .env file
dotenv()?;
@ -420,10 +421,11 @@ paths:
- lang: rust
label: Rust SDK (ckanaction) example
source: |
use ckanaction::CKANError;
use dotenvy::dotenv;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
async fn main() -> Result<(), CKANError> {
// Load environment variables from .env file
dotenv()?;
@ -814,10 +816,11 @@ paths:
- lang: rust
label: Rust SDK (ckanaction) example
source: |
use ckanaction::CKANError;
use dotenvy::dotenv;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
async fn main() -> Result<(), CKANError> {
// Load environment variables from .env file
dotenv()?;
@ -1024,10 +1027,11 @@ paths:
- lang: rust
label: Rust SDK (ckanaction) example
source: |
use ckanaction::CKANError;
use dotenvy::dotenv;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
async fn main() -> Result<(), CKANError> {
// Load environment variables from .env file
dotenv()?;

2
examples/package-list/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
.env
target/

1862
examples/package-list/Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,8 @@
[package]
name = "package-list"
version = "0.1.0"
edition = "2024"
[dependencies]
ckanaction = "0.2.0"
tokio = { version = "1.52.2", features = ["full"] }

View file

@ -0,0 +1,8 @@
# Example of using ckanaction to run the /package_list API endpoint
## Usage
the following command to run the `/package_list` CKAN Action API endpoint on `http://localhost:5000` and print the formatted debug output.
```bash
cargo run
```

View file

@ -0,0 +1,15 @@
use ckanaction::CKANError;
#[tokio::main]
async fn main() -> Result<(), CKANError> {
// Initialize and build CKAN struct
let ckan = ckanaction::CKAN::builder()
.url("http://localhost:5000")
.build();
// Send request to /package_list and print formatted debug output
let package_list = ckan.package_list().call().await?;
println!("{package_list:#?}");
Ok(())
}

File diff suppressed because it is too large Load diff

View file

@ -4,5 +4,5 @@ version = "0.1.0"
edition = "2024"
[dependencies]
ckanaction = "0.1.3"
tokio = { version = "1.49.0", features = ["full"] }
ckanaction = "0.2.0"
tokio = { version = "1.52.2", features = ["full"] }

View file

@ -1,6 +1,7 @@
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
use ckanaction::CKANError;
#[tokio::main]
async fn main() -> Result<(), CKANError> {
// Initialize and build CKAN struct
let ckan = ckanaction::CKAN::builder()
.url("http://localhost:5000")

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
use ckanaction::CKAN;
use ckanaction::{CKAN, CKANError};
const CKAN_API_TOKEN: &str = "";
const CKAN_URL: &str = "";
@ -12,7 +12,7 @@ pub async fn get_ckan_builder() -> CKAN {
#[tokio::test]
#[ignore = "Set values for const at top of tests file locally."]
async fn status_show() -> Result<(), Box<dyn std::error::Error>> {
async fn status_show() -> Result<(), CKANError> {
let ckan = get_ckan_builder().await;
let response = ckan.status_show().await?;
assert!(response.is_object());
@ -28,7 +28,7 @@ async fn status_show() -> Result<(), Box<dyn std::error::Error>> {
}
#[tokio::test]
async fn print_ckan_struct_with_debug() -> Result<(), Box<dyn std::error::Error>> {
async fn print_ckan_struct_with_debug() -> Result<(), CKANError> {
let ckan = get_ckan_builder().await;
assert_eq!(format!("{ckan:?}"), r#"CKAN { url: "", token: Some("") }"#);
Ok(())