Skip to main content

AsyncLagerBox

Struct AsyncLagerBox 

Source
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

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

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

Source

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

Check that the box HTTP server is up.

Source

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

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

Source

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

Handle for a power-supply net.

Source

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

Handle for a battery-simulator net.

Source

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

Handle for an electronic-load net.

Source

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

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

Source

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

Handle for a GPIO net.

Source

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

Handle for an ADC net.

Source

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

Handle for a DAC net.

Source

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

Handle for a thermocouple net.

Source

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

Handle for a watt-meter net.

Source

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

Handle for an energy-analyzer net.

Source

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

Handle for an SPI bus net.

Source

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

Handle for an I2C bus net.

Source

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

Handle for a USB hub port net.

Source

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

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

Source

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

Handle for a webcam net (MJPEG streaming).

Source

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

Handle for a router net (MikroTik RouterOS).

Source

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

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

Source

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

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

Source

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

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

Source

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.

Source

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

Handle for an oscilloscope net. Stub: see Scope.

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