[−][src]Trait lsl::Pullable
A trait that enables the methods pull_sample<T>()
and pull_chunk<T>()
.
Implemented by StreamInlet.
Required methods
fn pull_sample(&self, timeout: f64) -> Result<(Vec<T>, f64), Error>
Pull the next successive sample from an inlet and read it into a vector of values.
Handles type checking & conversion. When using this function keep in mind that, if you do not
pick up values for a while or at a sufficiently fast rate, you will fall behind in the data
stream (up to a maximum of the inlet's max_buflen
setting).
Arguments:
timeout
: The timeout for this operation, if any. If you use 0.0, the function will be non-blocking. You can also uselsl::FOREVER
to have no timeout.
Returns a tuple of (sample, timestamp)
, where sample
is a Vec<T>
of values in the sample
(each value corresponds to one channel, assuming the stream is multi-channel), and timestamp
is the capture time of the sample on the remote side (e.g., remote machine). If no new sample
was available, the sample vector will be empty and the timestamp will be 0.0 i.e., it will
not return an Error::Timeout
since we consider this a normal behavior.
If you want to remap the time stamp to the local machine's clock, you can enable the clock
synchronization option on the inlet using the set_postprocessing()
method. Alternatively that
can also be done manually by adding the return values of inlet's time_correction()
method.
fn pull_sample_buf(&self, buf: &mut Vec<T>, timeout: f64) -> Result<f64, Error>
Pull the next successive sample from an inlet into a provided buffer.
Handles type checking & conversion. When using this function keep in mind that, if you do not
pick up values for a while or at a sufficiently fast rate, you will fall behind in the data
stream (up to a maximum of the inlet's max_buflen
setting).
Arguments:
buf
: A mutable buffer into which this function will read the data; the buffer will be resized (if necessary) to match the number of channels of the stream.timeout
: The timeout for this operation, if any. If you use 0.0, the function will be non-blocking. You can also uselsl::FOREVER
to have no timeout.
Returns the capture time of the sample on the remote side (e.g., remote machine). If no new
sample was available, the returned timestamp will be 0.0, and the buffer will not be written to
(although it may be resized as needed) -- i.e., it will not return an Error::Timeout
since
we consider this a normal behavior.
If you want to remap the time stamp to the local machine's clock, you can enable the clock
synchronization option on the inlet using the set_postprocessing()
method. Alternatively that
can also be done manually by adding the return values of inlet's time_correction()
method.
Provided methods
fn pull_chunk(&self) -> Result<(Vec<Vec<T>>, Vec<f64>), Error>
Pull a chunk of new samples and their time stamps from the inlet.
This will return all new samples that you have not yet picked up since your last call (i.e., it can be anywhere between empty or a few-minute stretch).
Note You can configure the maximum amount of buffered data via the max_buflen
setting on the
inlet -- if you allow data to accomulate beyond this amount, the oldest data samples will be
discarded (for real-time processing applications it can make sense to set a low limit to avoid
wasting resources, while for recording applications, a high limit is recommended).
Implementors
impl Pullable<f32> for StreamInlet
[src]
fn pull_sample(&self, timeout: f64) -> Result<(Vec<f32>, f64), Error>
[src]
fn pull_sample_buf(
&self,
buf: &mut Vec<f32>,
timeout: f64
) -> Result<f64, Error>
[src]
&self,
buf: &mut Vec<f32>,
timeout: f64
) -> Result<f64, Error>
impl Pullable<f64> for StreamInlet
[src]
fn pull_sample(&self, timeout: f64) -> Result<(Vec<f64>, f64), Error>
[src]
fn pull_sample_buf(
&self,
buf: &mut Vec<f64>,
timeout: f64
) -> Result<f64, Error>
[src]
&self,
buf: &mut Vec<f64>,
timeout: f64
) -> Result<f64, Error>
impl Pullable<i8> for StreamInlet
[src]
fn pull_sample(&self, timeout: f64) -> Result<(Vec<i8>, f64), Error>
[src]
fn pull_sample_buf(&self, buf: &mut Vec<i8>, timeout: f64) -> Result<f64, Error>
[src]
impl Pullable<i16> for StreamInlet
[src]
fn pull_sample(&self, timeout: f64) -> Result<(Vec<i16>, f64), Error>
[src]
fn pull_sample_buf(
&self,
buf: &mut Vec<i16>,
timeout: f64
) -> Result<f64, Error>
[src]
&self,
buf: &mut Vec<i16>,
timeout: f64
) -> Result<f64, Error>
impl Pullable<i32> for StreamInlet
[src]
fn pull_sample(&self, timeout: f64) -> Result<(Vec<i32>, f64), Error>
[src]
fn pull_sample_buf(
&self,
buf: &mut Vec<i32>,
timeout: f64
) -> Result<f64, Error>
[src]
&self,
buf: &mut Vec<i32>,
timeout: f64
) -> Result<f64, Error>
impl Pullable<i64> for StreamInlet
[src]
fn pull_sample(&self, timeout: f64) -> Result<(Vec<i64>, f64), Error>
[src]
fn pull_sample_buf(
&self,
buf: &mut Vec<i64>,
timeout: f64
) -> Result<f64, Error>
[src]
&self,
buf: &mut Vec<i64>,
timeout: f64
) -> Result<f64, Error>
impl Pullable<String> for StreamInlet
[src]
fn pull_sample(&self, timeout: f64) -> Result<(Vec<String>, f64), Error>
[src]
fn pull_sample_buf(
&self,
buf: &mut Vec<String>,
timeout: f64
) -> Result<f64, Error>
[src]
&self,
buf: &mut Vec<String>,
timeout: f64
) -> Result<f64, Error>