qhyccd_rs/lib.rs
1//! # QHYCCD SDK bindings for Rust
2//!
3//! This crate provides a safe interface to the QHYCCD SDK for controlling QHYCCD cameras, filter wheels and focusers.
4//! The libqhyccd-sys crate provides the raw FFI bindings. It uses tracing for logging and eyre for error handling.
5//!
6//! # Example
7//! ```no_run
8//! use qhyccd_rs::Sdk;
9//! let sdk = Sdk::new().expect("SDK::new failed");
10//! let sdk_version = sdk.version().expect("get_sdk_version failed");
11//! println!("SDK version: {:?}", sdk_version);
12//! ```
13//!
14//! # Simulation Feature
15//!
16//! The `simulation` feature enables development and testing without physical hardware. When enabled,
17//! [`Sdk::new()`] automatically provides a simulated camera environment that behaves like real hardware.
18//!
19//! ## Enabling Simulation
20//!
21//! Add the feature to your `Cargo.toml`:
22//!
23//! ```toml
24//! [dependencies]
25//! qhyccd-rs = { version = "0.1.7", features = ["simulation"] }
26//! ```
27//!
28//! ## Transparent Usage
29//!
30//! With simulation enabled, your code works identically for both real and simulated cameras:
31//!
32//! ```no_run
33//! use qhyccd_rs::Sdk;
34//!
35//! // Same code works with or without the simulation feature
36//! let sdk = Sdk::new().expect("Failed to initialize SDK");
37//! let cameras = sdk.cameras();
38//! println!("Found {} camera(s)", cameras.count());
39//! ```
40//!
41//! ## Default Simulated Camera
42//!
43//! When compiled with the `simulation` feature, [`Sdk::new()`] automatically provides:
44//!
45//! - **Camera**: QHY178M-Simulated (`SIM-QHY178M`)
46//! - 3072x2048 resolution, 16-bit depth
47//! - Cooler support for temperature control
48//! - Full control API (gain, offset, exposure, etc.)
49//!
50//! - **Filter Wheel**: 7-position CFW
51//! - Accessible via [`Sdk::filter_wheels()`]
52//! - Complete control API support
53//!
54//! ## Custom Simulated Cameras
55//!
56//! For advanced use cases, use [`Sdk::new_simulated()`] and [`Sdk::add_simulated_camera()`]:
57//!
58//! ```
59//! # #[cfg(feature = "simulation")]
60//! # {
61//! use qhyccd_rs::{Sdk, simulation::SimulatedCameraConfig};
62//!
63//! let mut sdk = Sdk::new_simulated();
64//! let config = SimulatedCameraConfig::default()
65//! .with_id("CUSTOM-CAM")
66//! .with_filter_wheel(5);
67//! sdk.add_simulated_camera(config);
68//! # }
69//! ```
70#![warn(missing_debug_implementations, rust_2018_idioms, missing_docs)]
71
72#[macro_use]
73extern crate educe;
74
75// Module declarations
76mod backend;
77mod camera;
78mod control;
79mod error;
80mod filter_wheel;
81mod sdk;
82mod types;
83
84#[cfg(test)]
85pub mod mocks;
86
87#[cfg(feature = "simulation")]
88pub mod simulation;
89
90// Public re-exports
91pub use camera::Camera;
92pub use control::Control;
93pub use error::QHYError;
94pub use filter_wheel::FilterWheel;
95pub use sdk::Sdk;
96pub use types::{
97 BayerMode, CCDChipArea, CCDChipInfo, ImageData, ReadoutMode, SDKVersion, StreamMode,
98};
99
100// Unit tests requiring FFI mocking are in src/tests/
101// Simulation integration tests are in tests/simulation/
102#[cfg(test)]
103mod tests;