Skip to main content

LagerBox

Struct LagerBox 

Source
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

Source

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).

Source

pub fn from_env() -> Result<Self>

Connect to the box named by the LAGER_BOX_HOST environment variable.

Source

pub fn builder(host: impl Into<String>) -> LagerBoxBuilder

Start building a client with non-default settings.

Source

pub fn base_url(&self) -> &str

The base URL this client talks to, e.g. http://192.168.1.42:9000.

Source

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.

Source

pub fn health(&self) -> Result<Health>

Check that the box HTTP server is up.

Source

pub fn status(&self) -> Result<BoxStatus>

Box status: version, configured nets, and endpoint capabilities.

Source

pub fn supply(&self, name: impl Into<String>) -> Supply<'_>

Handle for a power-supply net.

Source

pub fn battery(&self, name: impl Into<String>) -> Battery<'_>

Handle for a battery-simulator net.

Source

pub fn eload(&self, name: impl Into<String>) -> Eload<'_>

Handle for an electronic-load net.

Source

pub fn solar(&self, name: impl Into<String>) -> Solar<'_>

Handle for a solar-simulator net (EA PSB photovoltaic mode).

Source

pub fn gpio(&self, name: impl Into<String>) -> Gpio<'_>

Handle for a GPIO net.

Source

pub fn adc(&self, name: impl Into<String>) -> Adc<'_>

Handle for an ADC net.

Source

pub fn dac(&self, name: impl Into<String>) -> Dac<'_>

Handle for a DAC net.

Source

pub fn thermocouple(&self, name: impl Into<String>) -> Thermocouple<'_>

Handle for a thermocouple net.

Source

pub fn watt_meter(&self, name: impl Into<String>) -> WattMeter<'_>

Handle for a watt-meter net.

Source

pub fn energy_analyzer(&self, name: impl Into<String>) -> EnergyAnalyzer<'_>

Handle for an energy-analyzer net.

Source

pub fn spi(&self, name: impl Into<String>) -> Spi<'_>

Handle for an SPI bus net.

Source

pub fn i2c(&self, name: impl Into<String>) -> I2c<'_>

Handle for an I2C bus net.

Source

pub fn usb(&self, name: impl Into<String>) -> UsbPort<'_>

Handle for a USB hub port net.

Source

pub fn arm(&self, name: impl Into<String>) -> Arm<'_>

Handle for a robot-arm net (Rotrics Dexarm).

Source

pub fn webcam(&self, name: impl Into<String>) -> Webcam<'_>

Handle for a webcam net (MJPEG streaming).

Source

pub fn router(&self, name: impl Into<String>) -> Router<'_>

Handle for a router net (MikroTik RouterOS).

Source

pub fn ble(&self) -> Ble<'_>

Handle for the box’s BLE adapter (box-level, not a saved net).

Source

pub fn wifi(&self) -> Wifi<'_>

Handle for the box’s WiFi interface (box-level, not a saved net).

Source

pub fn blufi(&self) -> Blufi<'_>

Handle for BluFi (ESP32 WiFi provisioning over BLE; box-level).

Source

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.

Source

pub fn scope(&self, name: impl Into<String>) -> Scope

Handle for an oscilloscope net. Stub: see Scope.

Source

pub fn uart(&self, name: impl Into<String>) -> Result<Uart>

Open a streaming UART session on a UART net.

Connects a Socket.IO session to the box’s /uart namespace and starts streaming. Only one session per net (box-enforced).

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more