fix: update docs and errors with CKANError

This commit is contained in:
rzmk 2026-05-05 16:48:56 -04:00
parent 677475f750
commit e5d4f8d442
5 changed files with 18 additions and 11 deletions

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: Run `/package_list` endpoint with a limit of 5 results per page and print the output:
```rust ```rust
use ckanaction::CKANError;
use dotenvy::dotenv; use dotenvy::dotenv;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> { async fn main() -> Result<(), CKANError> {
// Load environment variables from .env file // Load environment variables from .env file
dotenv()?; dotenv()?;

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: 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 ```rust
use ckanaction::CKANError;
use dotenvy::dotenv; use dotenvy::dotenv;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> { async fn main() -> Result<(), CKANError> {
// Load environment variables from .env file // Load environment variables from .env file
dotenv()?; dotenv()?;

View file

@ -48,10 +48,11 @@ paths:
- lang: rust - lang: rust
label: Rust SDK (ckanaction) example label: Rust SDK (ckanaction) example
source: | source: |
use ckanaction::CKANError;
use dotenvy::dotenv; use dotenvy::dotenv;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> { async fn main() -> Result<(), CKANError> {
// Load environment variables from .env file // Load environment variables from .env file
dotenv()?; dotenv()?;
@ -420,10 +421,11 @@ paths:
- lang: rust - lang: rust
label: Rust SDK (ckanaction) example label: Rust SDK (ckanaction) example
source: | source: |
use ckanaction::CKANError;
use dotenvy::dotenv; use dotenvy::dotenv;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> { async fn main() -> Result<(), CKANError> {
// Load environment variables from .env file // Load environment variables from .env file
dotenv()?; dotenv()?;
@ -814,10 +816,11 @@ paths:
- lang: rust - lang: rust
label: Rust SDK (ckanaction) example label: Rust SDK (ckanaction) example
source: | source: |
use ckanaction::CKANError;
use dotenvy::dotenv; use dotenvy::dotenv;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> { async fn main() -> Result<(), CKANError> {
// Load environment variables from .env file // Load environment variables from .env file
dotenv()?; dotenv()?;
@ -1024,10 +1027,11 @@ paths:
- lang: rust - lang: rust
label: Rust SDK (ckanaction) example label: Rust SDK (ckanaction) example
source: | source: |
use ckanaction::CKANError;
use dotenvy::dotenv; use dotenvy::dotenv;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> { async fn main() -> Result<(), CKANError> {
// Load environment variables from .env file // Load environment variables from .env file
dotenv()?; dotenv()?;

View file

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

View file

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