pub struct ActionDriverBuilder { /* private fields */ }Expand description
Builder for configuring ActionDriver with optional parameters
Implementations§
Source§impl ActionDriverBuilder
impl ActionDriverBuilder
Sourcepub fn new(addr: &str, port: u16) -> Self
pub fn new(addr: &str, port: u16) -> Self
Create a new builder with required connection parameters
Sourcepub fn with_connection_timeout(self, timeout: Duration) -> Self
pub fn with_connection_timeout(self, timeout: Duration) -> Self
Set connection timeout for the underlying NanonisClient
Sourcepub fn with_initial_storage(
self,
storage: HashMap<String, ActionResult>,
) -> Self
pub fn with_initial_storage( self, storage: HashMap<String, ActionResult>, ) -> Self
Initialize with pre-stored values
Sourcepub fn with_stored_value(self, key: String, value: ActionResult) -> Self
pub fn with_stored_value(self, key: String, value: ActionResult) -> Self
Add a single pre-stored value
Sourcepub fn with_tcp_reader(self, config: TCPReaderConfig) -> Self
pub fn with_tcp_reader(self, config: TCPReaderConfig) -> Self
Configure TCP Logger with always-buffer mode (recommended) This automatically starts BufferedTCPReader when ActionDriver is built
§Arguments
config- TCP logger configuration with buffer_size set
§Usage
let driver = ActionDriver::builder("127.0.0.1", 6501)
.with_tcp_reader(TCPReaderConfig {
stream_port: 6590,
channels: vec![0, 8],
oversampling: 100,
auto_start: true,
buffer_size: Some(10_000),
})
.build()?;
// Buffering is now active and ready for immediate data queriesSourcepub fn with_action_logging(
self,
file_path: impl Into<PathBuf>,
buffer_size: usize,
final_format_json: bool,
) -> Self
pub fn with_action_logging( self, file_path: impl Into<PathBuf>, buffer_size: usize, final_format_json: bool, ) -> Self
Configure action logging with buffered file output
§Arguments
file_path- Base path where action logs will be written (extension added automatically)buffer_size- Number of actions to buffer before auto-flushing to filefinal_format_json- If true, convert to JSON array on final flush; if false, keep JSONL format
§File Extensions
File extensions are added automatically based on the final format:
final_format_json = false→.jsonlextension (efficient streaming)final_format_json = true→.jsonextension (post-analysis friendly)
§Usage
// JSONL format (efficient, streaming) → experiment_actions.jsonl
let driver = ActionDriver::builder("127.0.0.1", 6501)
.with_action_logging("experiment_actions", 100, false)
.build()?;
// JSON format (better for post-analysis) → experiment_data.json
let driver = ActionDriver::builder("127.0.0.1", 6501)
.with_action_logging("experiment_data", 100, true)
.build()?;Sourcepub fn with_custom_tcp_mapping(self, mapping: &[(u8, u8)]) -> Self
pub fn with_custom_tcp_mapping(self, mapping: &[(u8, u8)]) -> Self
Provide custom Nanonis to TCP channel mapping
Override the default hardcoded mappings with your own. This is useful when your Nanonis configuration has different signal indices.
§Arguments
mapping- Array of (nanonis_index, tcp_channel) tuples
§Example
let custom_map = [
(76, 18), // Frequency shift
(0, 0), // Current
(24, 8), // Bias
];
let driver = ActionDriver::builder("127.0.0.1", 6501)
.with_custom_tcp_mapping(&custom_map)
.build()?;Sourcepub fn with_shutdown_flag(self, flag: Arc<AtomicBool>) -> Self
pub fn with_shutdown_flag(self, flag: Arc<AtomicBool>) -> Self
Set shutdown flag for graceful termination of long-running operations
When set, operations like stability checks will periodically check this flag
and return early with NanonisError::Protocol("Shutdown requested".to_string()) if it becomes true.
Sourcepub fn build(self) -> Result<ActionDriver, NanonisError>
pub fn build(self) -> Result<ActionDriver, NanonisError>
Build the ActionDriver with configured parameters and optional automatic buffering
Trait Implementations§
Source§impl Clone for ActionDriverBuilder
impl Clone for ActionDriverBuilder
Source§fn clone(&self) -> ActionDriverBuilder
fn clone(&self) -> ActionDriverBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more