Files
rustytorch/crates/specialized/rtx-neuro-lsl/src/lib.rs
T
2026-03-04 00:08:42 +00:00

59 lines
1.9 KiB
Rust

//! Lab Streaming Layer (LSL) integration for real-time MEG/EEG streaming
//!
//! This crate provides integration with the Lab Streaming Layer (LSL) protocol
//! for receiving real-time MEG/EEG data streams. LSL is the standard protocol
//! for streaming neural data in research settings.
//!
//! # Features
//!
//! - Stream discovery: Find available LSL streams on the network
//! - Real-time data reception: Connect to streams and receive samples
//! - Ring buffer: Efficient buffering of continuous data
//! - Async API: Non-blocking operations for use with Tauri
//!
//! # Note
//!
//! Full LSL support requires the native `liblsl` library to be installed.
//! Without the native library, this crate provides a mock implementation
//! suitable for development and testing.
//!
//! To enable native LSL support:
//! 1. Install liblsl from <https://github.com/sccn/liblsl>
//! 2. Rebuild with the `native` feature: `cargo build --features native`
//!
//! # Example
//!
//! ```no_run
//! use rtx_neuro_lsl::{LslService, LslStreamInfo};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let mut service = LslService::new();
//!
//! // Discover available streams (returns empty without native LSL)
//! let streams = service.discover_streams(1.0).await?;
//! println!("Found {} streams", streams.len());
//!
//! // For testing, create a mock stream
//! let info = LslStreamInfo::new("TestEEG", "EEG", 64, 256.0);
//! let handle = service.connect(info, 5.0).await?;
//!
//! // Get recent data
//! let (data, times) = service.get_data(&handle.id, 1.0).await?;
//! println!("Got {} samples", data.len());
//!
//! Ok(())
//! }
//! ```
pub mod buffer;
pub mod error;
pub mod service;
pub mod stream;
// Re-exports
pub use buffer::StreamBuffer;
pub use error::{LslError, Result};
pub use service::{LslHandle, LslService};
pub use stream::{ChannelFormat, LslSample, LslStreamInfo};