pub struct MockSourceBuilder { /* private fields */ }Expand description
Builder for MockSource instances.
Provides a fluent API for constructing mock sources with sensible defaults.
This is the recommended way to create a MockSource.
§Defaults
| Option | Default |
|---|---|
data_type | DataType::Generic |
interval_ms | 5000 |
dispatch_mode | Channel |
dispatch_buffer_capacity | 1000 |
auto_start | true |
§Example
ⓘ
use drasi_source_mock::{MockSource, DataType};
let source = MockSource::builder("my-source")
.with_data_type(DataType::sensor_reading(10))
.with_interval_ms(1000)
.with_auto_start(false) // Don't start automatically
.build()?;Implementations§
Source§impl MockSourceBuilder
impl MockSourceBuilder
Sourcepub fn new(id: impl Into<String>) -> Self
pub fn new(id: impl Into<String>) -> Self
Create a new builder with the given source ID.
§Arguments
id- Unique identifier for the source instance
Sourcepub fn with_data_type(self, data_type: DataType) -> Self
pub fn with_data_type(self, data_type: DataType) -> Self
Set the data type to generate.
§Arguments
data_type- One of:DataType::Counter,DataType::SensorReading { sensor_count }, orDataType::Generic(default)
For SensorReading, use DataType::sensor_reading(count) helper method.
Sourcepub fn with_interval_ms(self, interval_ms: u64) -> Self
pub fn with_interval_ms(self, interval_ms: u64) -> Self
Set the generation interval in milliseconds.
§Arguments
interval_ms- Interval between data generation (default: 5000)
Sourcepub fn with_dispatch_mode(self, mode: DispatchMode) -> Self
pub fn with_dispatch_mode(self, mode: DispatchMode) -> Self
Set the dispatch mode for event routing.
§Arguments
mode-Channel(default, with backpressure) orBroadcast
Sourcepub fn with_dispatch_buffer_capacity(self, capacity: usize) -> Self
pub fn with_dispatch_buffer_capacity(self, capacity: usize) -> Self
Set the dispatch buffer capacity.
§Arguments
capacity- Buffer size for dispatch channels (default: 1000)
Sourcepub fn with_bootstrap_provider(
self,
provider: impl BootstrapProvider + 'static,
) -> Self
pub fn with_bootstrap_provider( self, provider: impl BootstrapProvider + 'static, ) -> Self
Set the bootstrap provider for initial data delivery.
§Arguments
provider- Bootstrap provider implementation
Sourcepub fn with_auto_start(self, auto_start: bool) -> Self
pub fn with_auto_start(self, auto_start: bool) -> Self
Set whether this source should auto-start when DrasiLib starts.
Default is true. Set to false if this source should only be
started manually via start_source().
Auto Trait Implementations§
impl Freeze for MockSourceBuilder
impl !RefUnwindSafe for MockSourceBuilder
impl Send for MockSourceBuilder
impl Sync for MockSourceBuilder
impl Unpin for MockSourceBuilder
impl UnsafeUnpin for MockSourceBuilder
impl !UnwindSafe for MockSourceBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more