pub struct CortexConfig {
pub client_id: String,
pub client_secret: String,
pub cortex_url: String,
pub license: Option<String>,
pub decontaminated: bool,
pub allow_insecure_tls: bool,
pub timeouts: TimeoutConfig,
pub reconnect: ReconnectConfig,
pub health: HealthConfig,
}Expand description
Configuration for connecting to the Emotiv Cortex API.
§Examples
§From environment variables
use emotiv_cortex_v2::config::CortexConfig;
// Set EMOTIV_CLIENT_ID and EMOTIV_CLIENT_SECRET env vars, then:
let config = CortexConfig::from_env().expect("Missing env vars");§From a TOML file
use emotiv_cortex_v2::config::CortexConfig;
let config = CortexConfig::from_file("cortex.toml").expect("Bad config");§Programmatic
use emotiv_cortex_v2::config::CortexConfig;
let config = CortexConfig::new("my-client-id", "my-client-secret");Fields§
§client_id: StringCortex API client ID from the Emotiv Developer Portal.
client_secret: StringCortex API client secret.
cortex_url: StringWebSocket URL for the Cortex service.
license: Option<String>Emotiv license key for commercial/premium features.
decontaminated: boolRequest decontaminated EEG data (motion artifact removal).
allow_insecure_tls: boolAllow insecure TLS connections to non-localhost hosts. Only enable this for development/testing.
timeouts: TimeoutConfigTimeout configuration.
reconnect: ReconnectConfigAuto-reconnect configuration.
health: HealthConfigHealth monitoring configuration.
Implementations§
Source§impl CortexConfig
impl CortexConfig
Sourcepub fn new(
client_id: impl Into<String>,
client_secret: impl Into<String>,
) -> Self
pub fn new( client_id: impl Into<String>, client_secret: impl Into<String>, ) -> Self
Create a config with just client credentials (all other fields use defaults).
§Examples
use emotiv_cortex_v2::CortexConfig;
let config = CortexConfig::new("my-client-id", "my-client-secret");
assert_eq!(config.cortex_url, "wss://localhost:6868");
assert!(config.decontaminated);Sourcepub fn from_env() -> CortexResult<Self>
pub fn from_env() -> CortexResult<Self>
Load config from environment variables.
Required: EMOTIV_CLIENT_ID, EMOTIV_CLIENT_SECRET
Optional: EMOTIV_CORTEX_URL, EMOTIV_LICENSE
§Errors
Returns any error produced by the underlying Cortex API call, including connection, authentication, protocol, timeout, and configuration errors.
Sourcepub fn from_file(path: impl AsRef<Path>) -> CortexResult<Self>
pub fn from_file(path: impl AsRef<Path>) -> CortexResult<Self>
Load config from a TOML file, with environment variable overrides.
Environment variables take precedence over file values for
client_id, client_secret, cortex_url, and license.
§Errors
Returns any error produced by the underlying Cortex API call, including connection, authentication, protocol, timeout, and configuration errors.
Sourcepub fn discover(explicit_path: Option<&Path>) -> CortexResult<Self>
pub fn discover(explicit_path: Option<&Path>) -> CortexResult<Self>
Discover and load config from the standard search path:
- Explicit path (if
Some) CORTEX_CONFIGenvironment variable./cortex.toml~/.config/emotiv-cortex/cortex.toml
Falls back to environment-variable-only config if no file is found.
§Errors
Returns any error produced by the underlying Cortex API call, including connection, authentication, protocol, timeout, and configuration errors.
Sourcepub fn should_accept_invalid_certs(&self) -> bool
pub fn should_accept_invalid_certs(&self) -> bool
Returns true if insecure TLS should be allowed for the configured URL.
Insecure TLS is always allowed for localhost and 127.0.0.1
(the Cortex service uses a self-signed cert). For other hosts,
allow_insecure_tls must be explicitly set.
§Examples
use emotiv_cortex_v2::CortexConfig;
let config = CortexConfig::new("id", "secret");
assert!(config.should_accept_invalid_certs()); // localhost
let mut remote = CortexConfig::new("id", "secret");
remote.cortex_url = "wss://remote.example.com:6868".into();
assert!(!remote.should_accept_invalid_certs());Trait Implementations§
Source§impl Clone for CortexConfig
impl Clone for CortexConfig
Source§fn clone(&self) -> CortexConfig
fn clone(&self) -> CortexConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more