Skip to main content

libspot_rs/
lib.rs

1#![doc = include_str!("../README.md")]
2//!
3//! # Feature Flags
4//!
5//! - **`serde`** (enabled by default): Enables serialization and deserialization support for all model types
6//!   using the [`serde`](https://serde.rs/) framework. This is useful for:
7//!   - Saving trained models to disk
8//!   - Loading pre-trained models for deployment
9//!   - Sharing models between applications
10//!   - Checkpointing during long-running processes
11//!
12//!   To disable serialization support (e.g., for minimal dependencies), use:
13//!   ```toml
14//!   [dependencies]
15//!   libspot-rs = { version = "0.2", default-features = false }
16//!   ```
17//!
18//! ## Example with Serialization
19//!
20//! ```toml
21//! [dependencies]
22//! libspot-rs = { version = "0.2" }  # serde is enabled by default
23//! serde_json = "1.0"
24//! ```
25//!
26//! ```ignore
27//! use libspot_rs::{SpotConfig, SpotDetector};
28//! use serde_json;
29//!
30//! // Train a model
31//! let config = SpotConfig::default();
32//! let mut spot = SpotDetector::new(config).unwrap();
33//! let training_data: Vec<f64> = (0..1000).map(|i| i as f64 / 100.0).collect();
34//! spot.fit(&training_data).unwrap();
35//!
36//! // Serialize to JSON (serde is enabled by default)
37//! let json = serde_json::to_string(&spot).unwrap();
38//!
39//! // Save to file
40//! std::fs::write("model.json", &json).unwrap();
41//!
42//! // Later, load and continue using
43//! let json = std::fs::read_to_string("model.json").unwrap();
44//! let mut loaded: SpotDetector = serde_json::from_str(&json).unwrap();
45//! let status = loaded.step(50.0);
46//! ```
47
48mod config;
49mod error;
50mod estimator;
51mod math;
52mod p2;
53mod peaks;
54#[cfg(feature = "serde")]
55mod ser;
56mod spot;
57mod status;
58mod tail;
59mod ubend;
60
61// Re-export public types
62pub use config::SpotConfig;
63pub use error::{SpotError, SpotResult};
64pub use peaks::Peaks;
65pub use spot::SpotDetector;
66pub use status::SpotStatus;
67pub use tail::Tail;
68pub use ubend::Ubend;
69
70// Re-export commonly used types to match libspot crate
71pub use f64 as SpotFloat;
72
73/// Get the version of the pure Rust libspot implementation
74pub fn version() -> String {
75    env!("CARGO_PKG_VERSION").to_string()
76}