pub struct LagerBox { /* private fields */ }Expand description
A connection to one Lager box, over blocking HTTP.
Cheap to construct: no network traffic happens until the first call.
Net handles borrow the client, so a typical test creates one LagerBox
and any number of handles from it.
use lager::LagerBox;
fn main() -> lager::Result<()> {
let lager = LagerBox::connect("192.168.1.42")?;
let supply = lager.supply("supply1");
supply.set_voltage(3.3)?;
supply.enable()?;
let v = lager.adc("vbat_sense").read()?;
assert!((v - 3.3).abs() < 0.1);
supply.disable()
}Implementations§
Source§impl LagerBox
impl LagerBox
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>) -> LagerBoxBuilder
pub fn builder(host: impl Into<String>) -> LagerBoxBuilder
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 fn nets(&self) -> Result<Vec<NetRecord>>
pub 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 fn status(&self) -> Result<BoxStatus>
pub fn status(&self) -> Result<BoxStatus>
Box status: version, configured nets, and endpoint capabilities.
Sourcepub fn battery(&self, name: impl Into<String>) -> Battery<'_>
pub fn battery(&self, name: impl Into<String>) -> Battery<'_>
Handle for a battery-simulator net.
Sourcepub fn solar(&self, name: impl Into<String>) -> Solar<'_>
pub fn solar(&self, name: impl Into<String>) -> Solar<'_>
Handle for a solar-simulator net (EA PSB photovoltaic mode).
Sourcepub fn thermocouple(&self, name: impl Into<String>) -> Thermocouple<'_>
pub fn thermocouple(&self, name: impl Into<String>) -> Thermocouple<'_>
Handle for a thermocouple net.
Sourcepub fn watt_meter(&self, name: impl Into<String>) -> WattMeter<'_>
pub fn watt_meter(&self, name: impl Into<String>) -> WattMeter<'_>
Handle for a watt-meter net.
Sourcepub fn energy_analyzer(&self, name: impl Into<String>) -> EnergyAnalyzer<'_>
pub fn energy_analyzer(&self, name: impl Into<String>) -> EnergyAnalyzer<'_>
Handle for an energy-analyzer net.
Sourcepub fn arm(&self, name: impl Into<String>) -> Arm<'_>
pub fn arm(&self, name: impl Into<String>) -> Arm<'_>
Handle for a robot-arm net (Rotrics Dexarm).
Sourcepub fn webcam(&self, name: impl Into<String>) -> Webcam<'_>
pub fn webcam(&self, name: impl Into<String>) -> Webcam<'_>
Handle for a webcam net (MJPEG streaming).
Sourcepub fn router(&self, name: impl Into<String>) -> Router<'_>
pub fn router(&self, name: impl Into<String>) -> Router<'_>
Handle for a router net (MikroTik RouterOS).
Sourcepub fn wifi(&self) -> Wifi<'_>
pub fn wifi(&self) -> Wifi<'_>
Handle for the box’s WiFi interface (box-level, not a saved net).
Sourcepub fn blufi(&self) -> Blufi<'_>
pub fn blufi(&self) -> Blufi<'_>
Handle for BluFi (ESP32 WiFi provisioning over BLE; box-level).
Sourcepub fn debug(&self, name: impl Into<String>) -> DebugNet<'_>
pub fn debug(&self, name: impl Into<String>) -> DebugNet<'_>
Handle for a debug-probe net (flash/erase/reset/read_memory/RTT). Talks to the box debug service on port 8765.