1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//! # emotiv-cortex-v2
//!
//! A Rust client for the [Emotiv Cortex v2 WebSocket API](https://emotiv.gitbook.io/cortex-api/).
//!
//! This crate provides a complete, typed interface to the Emotiv Cortex service
//! for interacting with Emotiv EEG headsets (Insight, EPOC+, EPOC X, EPOC Flex).
//!
//! ## Quick Start
//!
//! ```no_run
//! use emotiv_cortex_v2::{CortexClient, CortexConfig};
//! use emotiv_cortex_v2::protocol::headset::QueryHeadsetsOptions;
//!
//! #[tokio::main]
//! async fn main() -> emotiv_cortex_v2::CortexResult<()> {
//! // Load config from environment or cortex.toml
//! let config = CortexConfig::discover(None)?;
//!
//! // Connect to the Cortex service
//! let mut client = CortexClient::connect(&config).await?;
//!
//! // Check service info
//! let info = client.get_cortex_info().await?;
//! println!("Cortex version: {:?}", info);
//!
//! // Authenticate
//! let _token = client.authenticate(&config.client_id, &config.client_secret).await?;
//!
//! // Discover headsets
//! let headsets = client.query_headsets(QueryHeadsetsOptions::default()).await?;
//! for h in &headsets {
//! println!("Found: {} ({})", h.id, h.status);
//! }
//!
//! client.disconnect().await?;
//! Ok(())
//! }
//! ```
//!
//! ## Two-Layer API
//!
//! | Layer | Type | Token mgmt | Reconnect | Retry | Best for |
//! |-------|------|-----------|-----------|-------|----------|
//! | Low-level | [`CortexClient`] | Manual | No | No | Examples, testing, full control |
//! | High-level | `ResilientClient` | Automatic | Yes | Yes | Production applications |
//!
//! ## Configuration
//!
//! See [`CortexConfig`] for the full configuration reference.
//! The simplest setup uses environment variables:
//!
//! ```bash
//! export EMOTIV_CLIENT_ID="your-client-id"
//! export EMOTIV_CLIENT_SECRET="your-client-secret"
//! ```
//!
//! Or a `cortex.toml` file:
//!
//! ```toml
//! client_id = "your-client-id"
//! client_secret = "your-client-secret"
//! ```
//!
//! ## Feature Flags
//!
//! TLS backend selection is explicit:
//! - `rustls-tls` (default)
//! - `native-tls`
//!
//! Exactly one TLS backend feature must be enabled.
//! `config-toml` (default) controls TOML parsing support in [`CortexConfig`];
//! when disabled, file-based config loading returns [`CortexError::ConfigError`].
//!
//! ## Protocol Modules
//!
//! Protocol types are grouped by domain:
//! - `protocol::rpc`
//! - `protocol::constants`
//! - `protocol::headset`
//! - `protocol::session`
//! - `protocol::streams`
//! - `protocol::records`
//! - `protocol::profiles`
//! - `protocol::training`
//! - `protocol::auth`
//! - `protocol::subjects`
compile_error!;
compile_error!;
// ─── Public re-exports ──────────────────────────────────────────────────
pub use CortexClient;
pub use CortexConfig;
pub use ;
pub use HeadsetModel;
pub use ResilientClient;
pub use TypedStream;