Skip to main content

Crate instrument

Crate instrument 

Source
Expand description

High-level instrument discovery and typed IVI-inspired classes.

§Quick start (mock, no VISA)

use instrument::prelude::*;

let fixture = ScriptedFixture::builder()
    .idn("Acme", "DMM1", "SN1", "1.0")
    .kinds([InstrumentKind::Dmm])
    .on_query(":MEAS:VOLT:DC?", "1.0")
    .build();
let catalog = DeviceCatalog::from_fixture("mock://dmm", fixture)?;

§Quick start (hardware)

Requires the visa feature (enabled by default).

ⓘ
use instrument::prelude::*;
let catalog = Discovery::visa()?.scan()?;

§Quick start (async mock, tokio feature)

ⓘ
use instrument::prelude::*;

#[tokio::main]
async fn main() -> Result<()> {
    let fixture = ScriptedFixture::builder()
        .idn("Acme", "DMM1", "SN1", "1.0")
        .kinds([InstrumentKind::Dmm])
        .on_query(":MEAS:VOLT:DC?", "1.0")
        .build();
    let catalog = AsyncDeviceCatalog::from_fixture("mock://dmm", fixture).await?;
    let mut dmm = catalog.open_dmm("mock://dmm").await?;
    println!("{} V", dmm.measure_voltage_dc(None).await?);
    Ok(())
}

See the user guide, getting started, and async guide.

Re-exports§

pub use catalog::DeviceCatalog;
pub use device::DeviceRef;
pub use discovery::Discovery;
pub use self;

Modules§

catalog
classes
device
discovery
mock_backend
prelude

Structs§

AccessMode
VISA access mode (maps to visa-rs AccessMode when using visa backend).
CommsEvent
A single communication event for observer push and tracing.
ConnectOptions
Options when opening an instrument session.
DeviceHealth
Pollable health snapshot for a device address.
DeviceId
Stable device identity for replacement and reconnection workflows.
Diagnostics
Shared diagnostics context injected into SCPI sessions.
DiscoveredDevice
A discovered device in the catalog.
Idn
Parsed *IDN? response.
InstrumentSession
Active instrument session with SCPI and cached identity.
MockTransport
Scripted request/response transport for deterministic CI.
ResourceAddress
Typed VISA resource address with canonical dedup key.
ScpiSession
SCPI session over a boxed transport.
ScriptedFixture
High-level fixture builder for common instrument patterns.
SessionPool
Reuses a single underlying session across typed views.
SharedRm
Shared resource manager — keeps the strong RM alive while sessions exist.
TransportIdentity
Optional pre-SCPI identity hints from the transport backend.
VisaEnumerator
VISA-backed resource enumerator.
VisaSessionOpener
Opens VISA sessions for instrument-core.

Enums§

CommsEventKind
Kind of communication event.
Error
Core error type — VISA-free; backend errors are boxed.
InstrumentKind
Instrument functional class (IVI-inspired).
ProbePolicy
How aggressively discovery probes instrument capabilities.

Traits§

CommsObserver
Receives push notifications for instrument communication events.
Transport
Swappable byte-level transport for instrument I/O.

Type Aliases§

Result