pub struct AsyncLagerBox { /* private fields */ }Expand description
A connection to one Lager box, over async HTTP (reqwest/tokio).
use lager::AsyncLagerBox;
#[tokio::main]
async fn main() -> lager::Result<()> {
let lager = AsyncLagerBox::connect("192.168.1.42")?;
let supply = lager.supply("supply1");
supply.set_voltage(3.3).await?;
supply.enable().await?;
let v = lager.adc("vbat_sense").read().await?;
assert!((v - 3.3).abs() < 0.1);
supply.disable().await
}Implementations§
Source§impl AsyncLagerBox
impl AsyncLagerBox
Sourcepub fn connect(host: impl Into<String>) -> Result<Self>
pub fn connect(host: impl Into<String>) -> Result<Self>
Connect to a box by host name, IP, host:port, or full URL.
The port defaults to 9000 (the box HTTP server).
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Connect to the box named by the LAGER_BOX_HOST environment
variable.
Sourcepub fn builder(host: impl Into<String>) -> AsyncLagerBoxBuilder
pub fn builder(host: impl Into<String>) -> AsyncLagerBoxBuilder
Start building a client with non-default settings.
Sourcepub fn base_url(&self) -> &str
pub fn base_url(&self) -> &str
The base URL this client talks to, e.g. http://192.168.1.42:9000.
Sourcepub async fn nets(&self) -> Result<Vec<NetRecord>>
pub async fn nets(&self) -> Result<Vec<NetRecord>>
List every net configured on the box (full saved records).
Falls back to the older /uart/nets/list shape for box images that
predate /nets/list, like the Lager CLI does.
Sourcepub async fn status(&self) -> Result<BoxStatus>
pub async fn status(&self) -> Result<BoxStatus>
Box status: version, configured nets, and endpoint capabilities.
Sourcepub fn supply(&self, name: impl Into<String>) -> AsyncSupply<'_>
pub fn supply(&self, name: impl Into<String>) -> AsyncSupply<'_>
Handle for a power-supply net.
Sourcepub fn battery(&self, name: impl Into<String>) -> AsyncBattery<'_>
pub fn battery(&self, name: impl Into<String>) -> AsyncBattery<'_>
Handle for a battery-simulator net.
Sourcepub fn eload(&self, name: impl Into<String>) -> AsyncEload<'_>
pub fn eload(&self, name: impl Into<String>) -> AsyncEload<'_>
Handle for an electronic-load net.
Sourcepub fn solar(&self, name: impl Into<String>) -> AsyncSolar<'_>
pub fn solar(&self, name: impl Into<String>) -> AsyncSolar<'_>
Handle for a solar-simulator net (EA PSB photovoltaic mode).
Sourcepub fn thermocouple(&self, name: impl Into<String>) -> AsyncThermocouple<'_>
pub fn thermocouple(&self, name: impl Into<String>) -> AsyncThermocouple<'_>
Handle for a thermocouple net.
Sourcepub fn watt_meter(&self, name: impl Into<String>) -> AsyncWattMeter<'_>
pub fn watt_meter(&self, name: impl Into<String>) -> AsyncWattMeter<'_>
Handle for a watt-meter net.
Sourcepub fn energy_analyzer(
&self,
name: impl Into<String>,
) -> AsyncEnergyAnalyzer<'_>
pub fn energy_analyzer( &self, name: impl Into<String>, ) -> AsyncEnergyAnalyzer<'_>
Handle for an energy-analyzer net.
Sourcepub fn usb(&self, name: impl Into<String>) -> AsyncUsbPort<'_>
pub fn usb(&self, name: impl Into<String>) -> AsyncUsbPort<'_>
Handle for a USB hub port net.
Sourcepub fn arm(&self, name: impl Into<String>) -> AsyncArm<'_>
pub fn arm(&self, name: impl Into<String>) -> AsyncArm<'_>
Handle for a robot-arm net (Rotrics Dexarm).
Sourcepub fn webcam(&self, name: impl Into<String>) -> AsyncWebcam<'_>
pub fn webcam(&self, name: impl Into<String>) -> AsyncWebcam<'_>
Handle for a webcam net (MJPEG streaming).
Sourcepub fn router(&self, name: impl Into<String>) -> AsyncRouter<'_>
pub fn router(&self, name: impl Into<String>) -> AsyncRouter<'_>
Handle for a router net (MikroTik RouterOS).
Sourcepub fn ble(&self) -> AsyncBle<'_>
pub fn ble(&self) -> AsyncBle<'_>
Handle for the box’s BLE adapter (box-level, not a saved net).
Sourcepub fn wifi(&self) -> AsyncWifi<'_>
pub fn wifi(&self) -> AsyncWifi<'_>
Handle for the box’s WiFi interface (box-level, not a saved net).
Sourcepub fn blufi(&self) -> AsyncBlufi<'_>
pub fn blufi(&self) -> AsyncBlufi<'_>
Handle for BluFi (ESP32 WiFi provisioning over BLE; box-level).
Sourcepub fn debug(&self, name: impl Into<String>) -> AsyncDebugNet<'_>
pub fn debug(&self, name: impl Into<String>) -> AsyncDebugNet<'_>
Handle for a debug-probe net (flash/erase/reset/read_memory). Talks to the box debug service on port 8765.