ferrtable/ferrtable/src/lib.rs
2026-01-11 20:42:42 +00:00

97 lines
2.5 KiB
Rust

//! # Ferrtable: Ferris the Crab's Favorite Airtable Client
//!
//! ## Status: Work in Progress
//!
//! Only a limited set of operations are currently supported. Any version bumps
//! before version 0.1 may include breaking changes to the crate API.
//!
//! ## Usage
//!
//! ```no_run
//! use std::error::Error;
//!
//! use futures::prelude::*;
//! use serde::{Deserialize, Serialize};
//!
//! // Ferrtable allows us to use any record types that implement Clone,
//! // Deserialize, and Serialize.
//! ##[derive(Clone, Debug, Deserialize, Serialize)]
//! struct MyRecord {
//! #[serde(rename = "Name")]
//! name: String,
//!
//! #[serde(rename = "Notes")]
//! notes: String,
//!
//! #[serde(rename = "Assignee")]
//! assignee: Option<String>,
//!
//! #[serde(rename = "Status")]
//! status: Status,
//!
//! #[serde(rename = "Attachments")]
//! attachments: Vec<ferrtable::cell_values::AttachmentRead>,
//! }
//!
//! ##[derive(Clone, Debug, Deserialize, Serialize)]
//! enum Status {
//! Todo,
//!
//! #[serde(rename = "In progress")]
//! InProgress,
//!
//! Done,
//! }
//!
//! ##[tokio::main]
//! async fn main() -> Result<(), Box<dyn Error>> {
//! let client = ferrtable::Client::new_from_access_token("******")?;
//!
//! client
//! .create_records([MyRecord {
//! name: "Steal Improbability Drive".to_owned(),
//! notes: "Just for fun, no other reason.".to_owned(),
//! assignee: None,
//! status: Status::InProgress,
//! attachments: vec![],
//! }])
//! .with_base_id("***")
//! .with_table_id("***")
//! .execute()
//! .await?;
//!
//! let mut rec_stream = client
//! .list_records()
//! .with_base_id("***")
//! .with_table_id("***")
//! .with_filter("{status} = 'Todo' || {status} = 'In Progress'")
//! .stream_items::<MyRecord>()?;
//!
//! while let Some(result) = rec_stream.next().await {
//! dbg!(result?.fields);
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! ## Features
//!
//! ### `chrono`
//!
//! Deserializes certain Airtable timestamp fields as `chrono::DateTime` values
//! instead of [`String`]s. Disabled by default.
pub mod cell_values;
pub mod client;
pub mod errors;
mod pagination;
pub mod types;
// Each API operation is organized into a dedicated Rust module.
pub mod create_records;
pub mod get_record;
pub mod list_bases;
pub mod list_records;
pub use client::Client;