[][src]Trait lsl::Pullable

pub trait Pullable<T> {
    fn pull_sample(&self, timeout: f64) -> Result<(Vec<T>, f64), Error>;
fn pull_sample_buf(
        &self,
        buf: &mut Vec<T>,
        timeout: f64
    ) -> Result<f64, Error>; fn pull_chunk(&self) -> Result<(Vec<Vec<T>>, Vec<f64>), Error> { ... } }

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 use lsl::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 use lsl::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.

Loading content...

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).

Loading content...

Implementors

impl Pullable<f32> for StreamInlet[src]

impl Pullable<f64> for StreamInlet[src]

impl Pullable<i8> for StreamInlet[src]

impl Pullable<i16> for StreamInlet[src]

impl Pullable<i32> for StreamInlet[src]

impl Pullable<i64> for StreamInlet[src]

impl Pullable<String> for StreamInlet[src]

impl Pullable<Vec<u8>> for StreamInlet[src]

Loading content...