Skip to main content

Fleet

Struct Fleet 

Source
pub struct Fleet { /* private fields */ }
Expand description

A real fleet a project fills and the dashboard renders. Clone to share one between the serving layer and the sampling loop.

Implementations§

Source§

impl Fleet

Source

pub fn builder() -> FleetBuilder

Starts building a fleet’s initial structure.

§Returns

An empty FleetBuilder.

Source

pub fn from_state(state: State) -> Self

Restores a fleet from a previously saved State, for a gateway that persists its fleet across restarts (save what snapshot returns, reload it here on boot).

§Arguments
  • state - the fleet structure and last readings to restore.
§Returns

A fleet holding the restored state.

Source

pub fn allow_sensors(&self, keys: impl IntoIterator<Item = impl Into<String>>)

Restricts which sensor types a client may add, so a real device only accepts the sensors it can bind a driver to.

Without this, an AddSensor from the dashboard is always accepted (which suits the hardware-free demo). With it, a client AddSensor whose element key is not listed is rejected with CommandError::UnknownSensor, and the dashboard reports that the device does not support that sensor. Discovery through add_sensor is the device’s own and stays unrestricted. Set this after building or restoring the fleet; the keys are the element keys a deployment supports, the same ones its presentation declares.

§Arguments
  • keys - the sensor element keys a client may add, such as "soil_moisture".
Source

pub fn report_reading(&self, group: &str, sensor: &str, reading: Reading)

Pushes a fresh reading for a sensor, appending it to the sensor’s history.

§Arguments
  • group - the sensor’s group id.
  • sensor - the sensor id.
  • reading - the new reading (the caller sets its status and band).
Source

pub fn report_event(&self, group: &str, sensor: &str, event: EventRecord)

Records a recent event for a sensor, newest first.

§Arguments
  • group - the sensor’s group id.
  • sensor - the sensor id.
  • event - the event to record.

Updates a group’s link status (kind, signal strength, online).

§Arguments
  • group - the group id.
  • link - the new link status.
Source

pub fn report_power( &self, group: &str, sensor: &str, mode: Mode, battery: Option<f32>, )

Updates a sensor’s power mode and battery state of charge.

§Arguments
  • group - the sensor’s group id.
  • sensor - the sensor id.
  • mode - the work cadence the sensor’s node is running at.
  • battery - the state of charge in [0.0, 1.0], or None if it has no battery.
Source

pub fn take_commands(&self) -> Vec<Command>

Drains the control commands queued since the last call, for the project to apply to real hardware and persist, then reflect back through the report methods.

§Returns

The commands accepted since the last drain, in order.

Source

pub fn add_group(&self, org: &str, group: Group)

Adds a group to an organization at runtime, so a gateway can surface a node the moment it is discovered (a LoRa join, a new mesh neighbour). A no-op if the org is unknown.

§Arguments
  • org - the organization id to add the group to.
  • group - the group to add.
Source

pub fn add_sensor(&self, group: &str, sensor: Sensor)

Adds a sensor to a group at runtime, for a newly discovered sensor. A no-op if the group is unknown.

§Arguments
  • group - the group id to add the sensor to.
  • sensor - the sensor to add.
Source

pub fn remove_group(&self, id: &str)

Removes a group by id at runtime, for a node that has gone away.

§Arguments
  • id - the group id to remove.
Source

pub fn remove_sensor(&self, target: &str)

Removes a sensor by its "groupId/sensorId" path at runtime.

§Arguments
  • target - the "groupId/sensorId" path to remove.

Trait Implementations§

Source§

impl Clone for Fleet

Source§

fn clone(&self) -> Fleet

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl StateSource for Fleet

Source§

fn snapshot(&mut self) -> State

Returns the node’s current state snapshot. Read more
Source§

fn command(&mut self, command: &Command) -> Result<(), CommandError>

Carries out an authenticated control command, changing the node’s state. Read more
Source§

fn select(&mut self, key: &str) -> bool

Switches a named view, for development and debugging only. Read more

Auto Trait Implementations§

§

impl Freeze for Fleet

§

impl RefUnwindSafe for Fleet

§

impl Send for Fleet

§

impl Sync for Fleet

§

impl Unpin for Fleet

§

impl UnsafeUnpin for Fleet

§

impl UnwindSafe for Fleet

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
§

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

§

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

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

§

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.