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: u32Points per second output rate.
target_buffer: DurationTarget 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: IdlePolicyWhat to do when the stream is idle (underrun or disarmed).
drain_timeout: DurationMaximum 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: DurationInitial 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: DurationDuration 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
impl StreamConfig
Sourcepub const DEFAULT_TARGET_BUFFER: Duration
pub const DEFAULT_TARGET_BUFFER: Duration
Baseline default target buffer used by StreamConfig::new().
Sourcepub const NETWORK_DEFAULT_TARGET_BUFFER: Duration
pub const NETWORK_DEFAULT_TARGET_BUFFER: Duration
Safer default target buffer for network DACs when caller leaves defaults untouched.
Sourcepub fn with_target_buffer(self, duration: Duration) -> Self
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.
Sourcepub fn with_idle_policy(self, policy: IdlePolicy) -> Self
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.
Sourcepub fn with_underrun(self, policy: IdlePolicy) -> Self
👎Deprecated since 0.8.0: renamed to with_idle_policy
pub fn with_underrun(self, policy: IdlePolicy) -> Self
renamed to with_idle_policy
Deprecated — use with_idle_policy instead.
Sourcepub fn with_drain_timeout(self, timeout: Duration) -> Self
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.
Sourcepub fn with_color_delay(self, delay: Duration) -> Self
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.
Sourcepub fn with_startup_blank(self, duration: Duration) -> Self
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.
Sourcepub fn with_reconnect(self, config: ReconnectConfig) -> Self
pub fn with_reconnect(self, config: ReconnectConfig) -> Self
Enable automatic reconnection (builder pattern).
Requires the device to have been opened via open_device.