Skip to main content

SimNode

Struct SimNode 

Source
pub struct SimNode {
    pub spec: NodeSpec,
    pub id: Option<u16>,
    pub awake: bool,
    pub powered: bool,
    pub granted: Vec<SecurityClass>,
    pub sensors: BTreeMap<u8, f64>,
    pub switch_on: bool,
    pub lifeline: Vec<u8>,
    pub wake_interval: u32,
    pub firmware: Vec<u8>,
    pub params: BTreeMap<u8, (u8, i32)>,
    pub received: Vec<Vec<u8>>,
    /* private fields */
}
Expand description

A simulated node’s state.

Fields§

§spec: NodeSpec

What it is.

§id: Option<u16>

Its node id once included.

§awake: bool

Awake (sleeping nodes).

§powered: bool

Powered; a node without power answers nothing.

§granted: Vec<SecurityClass>

Classes it holds keys for after inclusion.

§sensors: BTreeMap<u8, f64>

Sensor readings by type.

§switch_on: bool

Switch state.

§lifeline: Vec<u8>

Lifeline (association group 1).

§wake_interval: u32

Configured wake-up interval.

§firmware: Vec<u8>

The installed firmware image.

§params: BTreeMap<u8, (u8, i32)>

Configuration parameters: size and value.

§received: Vec<Vec<u8>>

Every command received, decrypted, for tests to inspect.

Implementations§

Source§

impl SimNode

Source

pub fn new(spec: NodeSpec) -> Self

A node out of any network.

Source

pub fn join(&mut self, id: u16, home_id: u32)

Joins a network as id.

Source

pub fn leave(&mut self)

Leaves the network (excluded or reset).

Source

pub fn reachable(&self) -> bool

Whether frames reach it now.

Source

pub fn unsolicited(&mut self, cmd: Command) -> Vec<Vec<u8>>

Something the node sends on its own (a report to its lifeline).

Source

pub fn wake(&mut self) -> Vec<Vec<u8>>

A Wake Up Notification.

Source

pub fn receive(&mut self, frame: &[u8]) -> Vec<Vec<u8>>

Handles a frame from the controller; returns frames to send back.

Source

pub fn sensor_report(&self, sensor_type: u8) -> Option<Command>

A multilevel sensor report for sensor_type, as the node would send it.

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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