pub struct StreamOptions {
pub poll_interval: Duration,
pub buffer_size: usize,
pub include_errors: bool,
pub max_consecutive_failures: Option<u32>,
}Expand description
Options for reading streams.
Use the builder pattern for convenient configuration:
let options = StreamOptions::builder()
.poll_interval(Duration::from_secs(5))
.include_errors(true)
.max_consecutive_failures(5)
.build();Fields§
§poll_interval: DurationPolling interval for devices that don’t support notifications. Default: 1 second.
buffer_size: usizeBuffer size for the reading channel. Default: 16 readings.
include_errors: boolWhether to include failed reads in the stream.
When false (default), read errors are logged but not sent to the stream.
When true, errors are sent as Err(Error) items, allowing the consumer
to detect and handle connection issues.
Recommendation: Set to true for applications that need to detect
disconnections or errors in real-time.
max_consecutive_failures: Option<u32>Maximum consecutive failures before auto-closing the stream.
When set to Some(n), the stream will automatically close after n
consecutive read failures, indicating a likely disconnection.
When None (default), the stream will continue indefinitely regardless
of failures.
Recommendation: Set to Some(5) or similar for production use to
prevent indefinite polling of a disconnected device.
Implementations§
Source§impl StreamOptions
impl StreamOptions
Sourcepub fn builder() -> StreamOptionsBuilder
pub fn builder() -> StreamOptionsBuilder
Create a new builder for StreamOptions.
Sourcepub fn with_interval(interval: Duration) -> Self
pub fn with_interval(interval: Duration) -> Self
Create options with a specific poll interval.
Trait Implementations§
Source§impl Clone for StreamOptions
impl Clone for StreamOptions
Source§fn clone(&self) -> StreamOptions
fn clone(&self) -> StreamOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more