haystack_client/lib.rs
1//! Haystack HTTP and WebSocket client library.
2//!
3//! Provides [`HaystackClient`] for communicating with Project Haystack servers
4//! using the standard REST API and optional WebSocket transport for real-time watches.
5//!
6//! ## Features
7//!
8//! - **SCRAM SHA-256 authentication** — Automatic handshake on connect
9//! - **HTTP + WebSocket** — HTTP for standard ops, WebSocket for watch subscriptions
10//! - **mTLS** — Mutual TLS via [`tls::TlsConfig`] for certificate-based auth
11//! - **Zinc wire format** — Default encoding for fastest serialization
12//! - **30+ Haystack ops** — about, read, nav, hisRead, hisWrite, pointWrite,
13//! watchSub, watchPoll, watchUnsub, invokeAction, defs, libs, and more
14//!
15//! ## Quick Start
16//!
17//! ```rust,no_run
18//! use haystack_client::HaystackClient;
19//!
20//! # async fn example() -> Result<(), haystack_client::ClientError> {
21//! let client = HaystackClient::connect("http://localhost:8080", "user", "pass").await?;
22//! let about = client.about().await?;
23//! let sites = client.read("site", None).await?;
24//! client.close().await;
25//! # Ok(())
26//! # }
27//! ```
28//!
29//! ## Error Handling
30//!
31//! All operations return `Result<_, ClientError>`. See [`ClientError`] for the
32//! error variants covering authentication, transport, codec, and timeout failures.
33
34pub mod auth;
35pub mod client;
36pub mod error;
37pub mod tls;
38pub mod transport;
39
40pub use client::HaystackClient;
41pub use error::ClientError;
42
43/// Install the ring crypto provider for rustls.
44///
45/// Called automatically by client constructors. Safe to call multiple times;
46/// only the first call has effect.
47pub fn ensure_crypto_provider() {
48 let _ = rustls::crypto::ring::default_provider().install_default();
49}