klafs_api/lib.rs
1//! Klafs Sauna Control Library
2//!
3//! This crate provides a Rust client for interacting with the Klafs sauna control API.
4//! It handles authentication, session management, and provides typed access to sauna
5//! status and control functions.
6//!
7//! # Features
8//!
9//! - Async API using tokio
10//! - Automatic cookie/session management
11//! - Strongly typed request/response models
12//! - Comprehensive error handling
13//! - HTTP traffic debugging
14//!
15//! # Example
16//!
17//! ```no_run
18//! use klafs_api::{KlafsClient, SaunaMode};
19//!
20//! #[tokio::main]
21//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
22//! // Create client and authenticate
23//! let client = KlafsClient::new()?;
24//! client.login("user@example.com", "password").await?;
25//!
26//! // Get sauna status
27//! let status = client.get_status("your-sauna-uuid").await?;
28//!
29//! println!("Connected: {}", status.is_connected);
30//! println!("Powered On: {}", status.is_powered_on);
31//! println!("Current Temperature: {}°C", status.current_temperature);
32//! println!("Target Temperature: {}°C", status.target_temperature());
33//!
34//! if let Some(mode) = status.current_mode() {
35//! println!("Mode: {}", mode);
36//! }
37//!
38//! Ok(())
39//! }
40//! ```
41//!
42//! # Debug Logging
43//!
44//! Enable HTTP traffic logging for debugging:
45//!
46//! ```no_run
47//! use klafs_api::{KlafsClient, ClientConfig, DebugConfig};
48//! use std::path::PathBuf;
49//!
50//! let config = ClientConfig {
51//! debug: DebugConfig::enabled().with_log_file(PathBuf::from("klafs-debug.log")),
52//! ..Default::default()
53//! };
54//!
55//! let client = KlafsClient::with_config(config)?;
56//! // All HTTP traffic will be logged to klafs-debug.log
57//! # Ok::<(), Box<dyn std::error::Error>>(())
58//! ```
59//!
60//! # Security Warning
61//!
62//! **Klafs locks accounts after 3 failed login attempts!**
63//!
64//! Be careful with automated login attempts and ensure credentials are correct
65//! before attempting to authenticate.
66
67mod client;
68pub mod debug;
69mod error;
70mod models;
71
72pub use client::{ClientConfig, KlafsClient, DEFAULT_BASE_URL};
73pub use debug::DebugConfig;
74pub use error::{KlafsError, Result};
75pub use models::{LightType, OpStatus, SaunaInfo, SaunaMode, SaunaStatus, StatusCode};