Skip to main content

StreamConfig

Struct StreamConfig 

Source
pub struct StreamConfig {
    pub pps: u32,
    pub target_buffer: Duration,
    pub idle_policy: IdlePolicy,
    pub drain_timeout: Duration,
    pub color_delay: Duration,
    pub startup_blank: Duration,
    pub reconnect: Option<ReconnectConfig>,
}
Expand description

Configuration for starting a stream.

§Buffer-Driven Timing

The streaming API uses pure buffer-driven timing:

  • target_buffer: Target buffer level to maintain (default baseline: 20ms)

The callback is invoked when buffered < target_buffer. The callback receives a ChunkRequest with target_points calculated from this duration and the current buffer state.

Dac::start_stream() may promote an untouched default to a safer network value for NetworkFifo / UdpTimed backends.

To reduce perceived latency, reduce target_buffer.

Fields§

§pps: u32

Points per second output rate.

§target_buffer: Duration

Target buffer level to maintain (default: 20ms).

The callback’s target_points is calculated to bring the buffer to this level. The callback is invoked when the buffer drops below this level.

§idle_policy: IdlePolicy

What to do when the stream is idle (underrun or disarmed).

§drain_timeout: Duration

Maximum time to wait for queued points to drain on graceful shutdown (default: 1s).

When the producer returns ChunkResult::End, the stream waits for buffered points to play out before returning. This timeout caps that wait to prevent blocking forever if the DAC stalls or queue depth is unknown.

§color_delay: Duration

Initial color delay for scanner sync compensation (default: disabled).

Delays RGB+intensity channels relative to XY coordinates by this duration, allowing galvo mirrors time to settle before the laser fires. The delay is implemented as a FIFO: output colors lag input colors by ceil(color_delay * pps) points.

Can be changed at runtime via crate::StreamControl::set_color_delay.

Typical values: 50–200µs depending on scanner speed. Duration::ZERO disables the delay (default).

§startup_blank: Duration

Duration of forced blanking after arming (default: 1ms).

After the stream is armed, the first ceil(startup_blank * pps) points will have their color channels forced to zero, regardless of what the producer writes. This prevents the “flash on start” artifact where the laser fires before mirrors reach position.

Note: when color_delay is also active, the delay line provides color_delay worth of natural startup blanking. This startup_blank setting adds blanking beyond that duration.

Set to Duration::ZERO to disable explicit startup blanking.

§reconnect: Option<ReconnectConfig>

Reconnection configuration (default: disabled).

Set via with_reconnect to enable automatic reconnection when the device disconnects.

Implementations§

Source§

impl StreamConfig

Source

pub const DEFAULT_TARGET_BUFFER: Duration

Baseline default target buffer used by StreamConfig::new().

Source

pub const NETWORK_DEFAULT_TARGET_BUFFER: Duration

Safer default target buffer for network DACs when caller leaves defaults untouched.

Source

pub fn new(pps: u32) -> Self

Create a new stream configuration with the given PPS.

Source

pub fn with_target_buffer(self, duration: Duration) -> Self

Set the target buffer level to maintain (builder pattern).

Default: 20ms. Higher values provide more safety margin against underruns. Lower values reduce perceived latency.

Source

pub fn with_idle_policy(self, policy: IdlePolicy) -> Self

Set the idle policy (builder pattern).

Controls behavior when the stream is idle — either because the producer can’t keep up (underrun) or the stream is disarmed. See IdlePolicy.

Source

pub fn with_underrun(self, policy: IdlePolicy) -> Self

👎Deprecated since 0.8.0:

renamed to with_idle_policy

Deprecated — use with_idle_policy instead.

Source

pub fn with_drain_timeout(self, timeout: Duration) -> Self

Set the drain timeout for graceful shutdown (builder pattern).

Default: 1 second. Set to Duration::ZERO to skip drain entirely.

Source

pub fn with_color_delay(self, delay: Duration) -> Self

Set the color delay for scanner sync compensation (builder pattern).

Default: Duration::ZERO (disabled). Typical values: 50–200µs.

Source

pub fn with_startup_blank(self, duration: Duration) -> Self

Set the startup blanking duration after arming (builder pattern).

Default: 1ms. Set to Duration::ZERO to disable.

Source

pub fn with_reconnect(self, config: ReconnectConfig) -> Self

Enable automatic reconnection (builder pattern).

Requires the device to have been opened via open_device.

Trait Implementations§

Source§

impl Debug for StreamConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StreamConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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.
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,