gtec
A Rust library and terminal UI for the g.tec Unicorn Hybrid Black 8-channel EEG headset via the Unicorn C API.
Rust FFI wrapper with 100% API parity — all 16 functions from unicorn.h bound,
all types mapped to #[repr(C)] Rust equivalents, SHA-256 verification, and
OS-level network sandboxing.
Installation
cargo add gtec
Supported hardware
| Device | Channels | Sampling Rate | Connection |
|---|---|---|---|
| Unicorn Hybrid Black | 8 EEG + 3 accel + 3 gyro + battery + counter + validation (17 total) | 250 Hz | Bluetooth |
Cross-platform
Works on Windows and Linux (x86_64). The Unicorn library is loaded at
runtime via libloading — no build-time C dependencies.
Note: No macOS native library is provided by g.tec.
Native library sources
| Platform | Repository | File |
|---|---|---|
| Windows | Unicorn-Hybrid-Black-Windows-APIs | Unicorn.dll |
| Linux | Unicorn-Suite-Hybrid-Black | libunicorn.so |
Quick start
use *;
Project layout
gtec-rs/
├── Cargo.toml
├── README.md
├── CHANGELOG.md
├── LICENSE
└── src/
├── lib.rs # Crate root + prelude
├── main.rs # CLI binary
├── bin/tui.rs # ratatui TUI (8-channel EEG charts)
├── ffi.rs # Runtime-loaded Unicorn C API (16 functions)
├── types.rs # #[repr(C)] types matching unicorn.h
├── device.rs # High-level device API
├── error.rs # Error types
├── verify.rs # SHA-256 integrity verification
└── sandbox.rs # OS-level network sandboxing
├── sdk/
│ ├── download.sh # Download + verify native libraries
│ └── checksums.sha256 # Pinned SHA-256 hashes
├── examples/
│ ├── scan.rs # Device discovery
│ ├── stream.rs # Signal streaming
│ └── read_eeg.rs # 4-second EEG capture
└── tests/
└── types_tests.rs # FFI type layout + constant tests
Dependencies
| Crate | Purpose |
|---|---|
| libloading | Runtime DLL/so loading |
| thiserror | Error type derivation |
| log | Logging facade |
| env_logger | Log output |
| libc | seccomp syscalls (Linux) |
| ratatui | Terminal UI (optional) |
| crossterm | Terminal backend (optional) |
Running tests