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 lives in
labstream-core, and those crates
stay exact to the C++ library at sccn/liblsl.
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
Version 0.1.0. The API can change before version 1.0.
Add the library to a program
The crate is labstream. This repository is labstream-rs, because a
repository of that name says which language it holds, and a crate on crates.io
holds Rust already.
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 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 |
Build and test
The tests need no hardware. They publish their own stream and read it back.
Conventions
Documents and code comments follow ASD-STE100 Simplified Technical English, as
in labstream-core. Before a pull request, run:
Correct every warning.
License
MIT.