labstream
The Lab Streaming Layer, for Rust programs.
This crate is the API that a Rust program calls. It holds no protocol code. The
protocol is in the crates of
labstream-core, and those crates
stay exact to the C++ library at sccn/liblsl. All of them are in one
repository, rednayan/labstream.
labstream this crate: the API a Rust program calls
/ \
labstream-capi labstream-net the protocol, exact to sccn/liblsl
|
labstream-proto, labstream-wire, labstream-time
Two APIs are necessary because one API cannot do both jobs. labstream-net answers to
the C++ source, line by line, and that is what makes the conformance claim true.
This crate answers to the person who writes the program.
Status
The API can change before version 1.0. This crate takes the version of the workspace, so its number is the number of the protocol crates that it calls.
Add the library to a program
Read a stream
use ;
use Duration;
let info = resolve_first?
.expect;
let mut inlet = builder
.buffer
.postprocess
.open?;
for c in inlet.info.channels
let mut chunk = new;
loop
Publish a stream
use ;
let info = builder
.rate
.source_id
.channels
.build?;
let outlet = new?;
outlet.push?;
What this crate adds
Each item comes from a port of a real application. docs/design.md in this
crate gives the measurements and the reason for each choice.
| Item | What it removes |
|---|---|
Chunk<T> and pull_chunk |
one lock and one allocation for each sample |
Chunk::channel |
the loop that turns samples into one buffer per channel |
StreamInfo::channels() |
the walk of the <channels> description tree |
StreamInfo::builder |
a channel count that disagrees with the channels |
Buffer::Seconds |
a buffer size whose unit the reader must guess |
Query |
a predicate that breaks on an apostrophe |
Post::CLOCK_SYNC |
a u32 whose legal values live in another crate |
Error::Lost |
one error type for "the source is gone" and "the socket failed" |
Scalar, as_f64, as_text |
a match over seven value formats in each program |
Watcher |
a browser that pays a full timeout for each refresh |
Inlet::health() and gaps() |
silent sample loss with no visibility into transport or queue fill |
InletBuilder::{channels, decimate, rate} |
client-side discard of unwanted channels over slow links (select/1) |
Outlet::push_metadata and Inlet::pull_metadata |
stream reconnects for live electrode impedance or battery updates (meta/1) |
SyncGroup |
manual multi-stream resampling and phase alignment across asynchronous ADCs |
ws, enc, calibrate, relay, doctor |
separate external tools for browser reach, encryption, delay calibration, relay, and network diagnostics |
Build and test
Run these commands from the repository root:
The tests need no hardware. They publish their own stream and read it back.
Conventions
CONTRIBUTING.md at the repository root gives the rules for a change. They
apply to this crate as to every other crate of the workspace.
License
MIT. Read LICENSE.