Skip to main content

chalk_client/
lib.rs

1//! # chalk-client
2//!
3//! The official [Chalk](https://chalk.ai) client library for Rust.
4//!
5//! Provides both an HTTP/REST client ([`ChalkClient`]) and a gRPC client
6//! ([`ChalkGrpcClient`]) for online queries, bulk queries, and feature uploads.
7//! Use the gRPC client for latency-sensitive workloads; use the HTTP client for
8//! offline queries and general use.
9//!
10//! ## Quick Start
11//!
12//! ```rust,no_run
13//! use chalk_client::ChalkClient;
14//! use chalk_client::types::QueryOptions;
15//! use std::collections::HashMap;
16//!
17//! # async fn example() -> chalk_client::error::Result<()> {
18//! let client = ChalkClient::new()
19//!     .client_id("your-client-id")
20//!     .client_secret("your-client-secret")
21//!     .environment("production")
22//!     .build()
23//!     .await?;
24//!
25//! let inputs = HashMap::from([
26//!     ("user.id".to_string(), serde_json::json!(42)),
27//! ]);
28//! let outputs = vec!["user.age".to_string(), "user.name".to_string()];
29//!
30//! let response = client.query(inputs, outputs, QueryOptions::default()).await?;
31//! for feature in &response.data {
32//!     println!("{}: {:?}", feature.field, feature.value);
33//! }
34//! # Ok(())
35//! # }
36//! ```
37
38pub mod error;
39pub mod types;
40pub mod config;
41pub mod auth;
42pub mod http_client;
43pub mod offline;
44pub mod gen;
45pub mod grpc_client;
46
47pub use http_client::{BulkQueryResult, ChalkClient};
48pub use grpc_client::ChalkGrpcClient;
49pub use offline::OfflineQueryParams;