Skip to main content

Inlet

Struct Inlet 

Source
pub struct Inlet { /* private fields */ }
Expand description

A connected inlet.

A background thread reads the socket and decodes samples into a bounded queue. The application pulls from that queue.

The split matters. A reader that decoded inside pull would leave the socket unread while the application worked, so a loss would land in the outlet’s queue instead of this one. liblsl runs the same background thread (src/data_receiver.h).

Implementations§

Source§

impl Inlet

Source

pub fn open(info: &StreamInfo, timeout: Duration) -> Result<Self>

Open a feed to a resolved stream. SPEC.md 4 and 6.

The call runs the whole handshake, including the two test pattern samples that open every feed.

Source

pub fn open_with_buffer( info: &StreamInfo, timeout: Duration, buffer_samples: i32, ) -> Result<Self>

Open a feed and choose the size of the queue, in samples.

The value also goes out in Max-Buffer-Length, which carries a count of samples. A caller that thinks in seconds converts first. SPEC.md 8.6.

Source

pub fn open_recovering( info: &StreamInfo, timeout: Duration, buffer_samples: i32, ) -> Result<Self>

Open a feed and choose whether the inlet finds the stream again after a restart of its source. SPEC.md 10.1.

liblsl enables recovery by default (include/lsl_cpp.h:915).

Source

pub fn set_postprocessing(&mut self, options: u32)

Choose the post-processing stages. SPEC.md 8.5.

The default applies none, so a timestamp arrives as the sender wrote it.

Source

pub fn set_postprocessing_all(&mut self)

Apply every stage: clock sync, then jitter removal, then the clamp.

Source

pub fn time_correction(&self) -> Option<f64>

The measured offset between the two clocks, or None before the first burst finishes.

Add this value to a timestamp to move it onto the local clock. The CLOCKSYNC stage does that on its own.

Source

pub fn wait_for_time_correction(&self, timeout: Duration) -> Option<f64>

Wait for a first offset measurement.

Source

pub fn time_uncertainty(&self) -> Option<f64>

The round-trip time of the estimate that the offset came from.

Source

pub fn info(&self) -> &StreamInfo

The description of the connected stream.

This is the short description that discovery returned. It carries an empty description tree. Call Inlet::fullinfo for the tree.

Source

pub fn fullinfo(&self, timeout: Duration) -> Result<StreamInfo>

Read the whole description, with the description tree.

The short description that a discovery answer carries has no tree (src/stream_info_impl.cpp:160). The tree travels on the data port. This opens its own connection, the way info_receiver does (src/info_receiver.cpp:60), and leaves the feed connection alone.

Source

pub fn pull(&mut self, timeout: Duration) -> Result<Option<Sample>>

Read one sample.

Returns Ok(None) when the timeout passes with no whole sample.

The timestamp passes through the post-processing stages that Inlet::set_postprocessing selected. With none selected the value is the one that the sender wrote.

Source

pub fn pull_chunk( &mut self, out: &mut Vec<Sample>, max: usize, timeout: Duration, ) -> Result<usize>

Read every sample that waits, up to max, with one lock.

The samples go to the end of out. The call gives how many it added. Every timestamp passes through the stages that Inlet::set_postprocessing selected, in the order of one Inlet::pull for each sample.

The timeout applies to the first sample only. The call never waits for max samples, because a program that shows live signals must show what arrived.

This is the call for a fast stream. Inlet::pull takes the queue lock and reads the clock for each sample. A stream of 8 channels at 1000 Hz therefore costs 1000 locks each second with pull, and one lock for each block here.

Source

pub fn samples_available(&self) -> usize

How many samples wait for the application.

Source

pub fn samples_dropped(&self) -> u64

How many samples the queue has dropped.

Nothing on the wire carries this number, so a peer cannot learn it. SPEC.md 8.7. This exists for a local report only.

Source

pub fn buffer_capacity(&self) -> usize

The size of the queue, in samples.

Source

pub fn is_finished(&self) -> bool

True once the connection ended and every sample has been pulled.

Source§

impl Inlet

Source

pub fn is_connected(&self) -> bool

True while the reader is attached to a source.

A recovery sets this to false until the stream is found again.

Source

pub fn recoveries(&self) -> u64

How many times the connection has been rebuilt. SPEC.md 10.1.

Source

pub fn current_info(&self) -> StreamInfo

The stream that the reader is attached to now.

A recovery replaces this, and the instance identifier changes while the name and the source identifier stay.

Trait Implementations§

Source§

impl Drop for Inlet

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl Freeze for Inlet

§

impl RefUnwindSafe for Inlet

§

impl Send for Inlet

§

impl Sync for Inlet

§

impl Unpin for Inlet

§

impl UnsafeUnpin for Inlet

§

impl UnwindSafe for Inlet

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.