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 open_selected( info: &StreamInfo, timeout: Duration, buffer_samples: i32, recover: bool, selection: SelectParam, ) -> Result<Self>

Open a feed requesting channel and/or rate selection (select/1, docs/roadmap.md, step 6).

If the outlet supports select/1, the returned inlet delivers only the selected channels at the selected rate, and Inlet::info and Inlet::fullinfo reflect the narrowed stream. If the outlet does not support select/1 (for example a liblsl outlet), the inlet falls back cleanly to the full stream and Inlet::selection returns None.

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. When flags::DEVICE_DELAY is enabled and no explicit delay was set via Inlet::set_device_delay, the inlet reads <desc><synchronization><offset_mean> from the stream description.

Source

pub fn set_device_delay(&mut self, delay_s: f64)

Set an explicit calibrated device delay (in seconds) subtracted when flags::DEVICE_DELAY is enabled (docs/roadmap.md, step 15).

Source

pub fn device_delay(&self) -> f64

The device delay (in seconds) currently configured on the post-processor.

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 clock_drift(&self) -> Option<f64>

Estimated relative clock drift (d(offset)/d(t_local) in s/s) from the opt-in drift clock (docs/roadmap.md, step 17), or None before the first burst completes.

Source

pub fn smooth_time_correction(&self, remote_ts: f64) -> Option<f64>

Smooth offset local - remote evaluated for remote_ts using the opt-in drift clock (docs/roadmap.md, step 17).

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.

When select/1 is active on this connection, the returned description carries the selected channel count, selected rate, and selected channel metadata under <desc><channels>.

Source

pub fn selection(&self) -> Option<SelectParam>

The active select/1 selection negotiated with the outlet, or None when the full stream is delivered.

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.

With CLOCKSYNC selected, the first call waits for the first offset measurement, for up to 5 s. The timeout of the call does not limit that wait. liblsl waits the same time (src/stream_inlet_impl.h:44).

Source

pub fn pull_numeric_into( &mut self, format: Format, dst: &mut [u8], timeout: Duration, ) -> Result<Option<f64>>

Read one numeric sample directly into dst (native-endian bytes), returning its timestamp.

On a shm/1 connection, copies directly from shared memory into dst with zero heap allocation and zero mutex locks.

Source

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

Read one PackedSample without allocating a Vec<Value>.

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.

With CLOCKSYNC selected, the first call can wait up to 5 s for the first offset measurement, as Inlet::pull does.

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 pull_chunk_packed( &mut self, out: &mut Vec<PackedSample>, max: usize, timeout: Duration, ) -> Result<usize>

Read every waiting PackedSample, up to max, with one lock and without allocating a Vec<Value>.

Source

pub fn pull_chunk_f32( &mut self, data: &mut Vec<f32>, timestamps: &mut Vec<f64>, max_samples: usize, timeout: Duration, ) -> Result<usize>

Read up to max_samples into flat f32 and timestamp buffers with one lock.

Source

pub fn pull_chunk_f64( &mut self, data: &mut Vec<f64>, timestamps: &mut Vec<f64>, max_samples: usize, timeout: Duration, ) -> Result<usize>

Read up to max_samples into flat f64 and timestamp buffers with one lock.

Source

pub fn pull_chunk_i32( &mut self, data: &mut Vec<i32>, timestamps: &mut Vec<f64>, max_samples: usize, timeout: Duration, ) -> Result<usize>

Read up to max_samples into flat i32 and timestamp buffers with one lock.

Source

pub fn pull_chunk_i16( &mut self, data: &mut Vec<i16>, timestamps: &mut Vec<f64>, max_samples: usize, timeout: Duration, ) -> Result<usize>

Read up to max_samples into flat i16 and timestamp buffers with one lock.

Source

pub fn pull_chunk_i8( &mut self, data: &mut Vec<i8>, timestamps: &mut Vec<f64>, max_samples: usize, timeout: Duration, ) -> Result<usize>

Read up to max_samples into flat i8 and timestamp buffers with one lock.

Source

pub fn pull_chunk_i64( &mut self, data: &mut Vec<i64>, timestamps: &mut Vec<f64>, max_samples: usize, timeout: Duration, ) -> Result<usize>

Read up to max_samples into flat i64 and timestamp buffers with one lock.

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 samples_lost(&self) -> Option<u64>

How many samples never reached this inlet, since it opened.

The count comes from the seq/1 numbers (docs/extensions.md). It shows a sample that the outlet dropped from a full queue, and the samples between a lost connection and the next one. The value is None when the current connection does not use seq/1, for example with a liblsl outlet. None means unknown, not zero.

The inlet queue drops after this count, so a full total adds Inlet::samples_dropped.

Source

pub fn samples_resent(&self) -> Option<u64>

How many samples came from the history of the outlet, since the inlet opened.

After a lost connection, an outlet with the resume/1 feature sends the samples of the dropout again (docs/extensions.md, section resume). These samples arrive late, with their original timestamps. Inlet::samples_lost does not count them.

The value is None when the current connection does not use resume/1. None means unknown, not zero.

Source

pub fn on_udp(&self) -> bool

True while the samples of the connection arrive on UDP, with the dgram/1 feature. docs/extensions.md, section dgram.

Source

pub fn on_shm(&self) -> bool

True while the samples of the connection arrive through shared memory, with the shm/1 feature (docs/extensions.md, section shm).

Source

pub fn is_compressed(&self) -> bool

True while wire compression (comp/1) is active on this connection.

Source

pub fn is_encrypted(&self) -> bool

True while negotiated transport encryption (enc/1) is active on this connection (docs/roadmap.md, step 14).

Source

pub fn has_live_metadata(&self) -> bool

True when the current connection negotiated meta/1 live metadata (docs/roadmap.md, step 16).

Source

pub fn pending_metadata_count(&self) -> usize

Number of unread live metadata updates currently queued on this inlet.

Source

pub fn pull_metadata(&self) -> Vec<MetadataUpdate>

Drain all pending live metadata updates in order.

Source

pub fn pull_metadata_one(&self) -> Option<MetadataUpdate>

Pop the oldest pending live metadata update, if any.

Source

pub fn metadata(&self) -> BTreeMap<String, MetadataUpdate>

Snapshot the latest live metadata value received for each key.

Source

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

Ratio wire_bytes / raw_bytes observed on this connection when comp/1 is active, or None when uncompressed or before data arrives.

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

pub fn health(&self) -> InletHealth

Snapshot the health of this inlet in one call. docs/health.md.

Source

pub fn gaps(&self) -> Vec<Gap>

Snapshot every gap recorded on this inlet, sorted by start timestamp.

Includes both network/outlet losses (GapKind::Lost) and local buffer overflows (GapKind::Dropped).

Source

pub fn take_gaps(&self) -> Vec<Gap>

Drain and return every finalized gap recorded since the last call, sorted by start timestamp.

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 Forget for Inlet

§

impl Freeze for Inlet

§

impl Move 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.