Skip to main content

ActionDriverBuilder

Struct ActionDriverBuilder 

Source
pub struct ActionDriverBuilder { /* private fields */ }
Expand description

Builder for configuring ActionDriver with optional parameters

Implementations§

Source§

impl ActionDriverBuilder

Source

pub fn new(addr: &str, port: u16) -> Self

Create a new builder with required connection parameters

Source

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

Set connection timeout for the underlying NanonisClient

Source

pub fn with_initial_storage( self, storage: HashMap<String, ActionResult>, ) -> Self

Initialize with pre-stored values

Source

pub fn with_stored_value(self, key: String, value: ActionResult) -> Self

Add a single pre-stored value

Source

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 queries
Source

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 file
  • final_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.jsonl extension (efficient streaming)
  • final_format_json = true.json extension (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()?;
Source

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()?;
Source

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.

Source

pub fn build(self) -> Result<ActionDriver, NanonisError>

Build the ActionDriver with configured parameters and optional automatic buffering

Trait Implementations§

Source§

impl Clone for ActionDriverBuilder

Source§

fn clone(&self) -> ActionDriverBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ActionDriverBuilder

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.