Callbacks

Struct Callbacks 

Source
pub struct Callbacks<'a> {
    pub store_node_config: Option<&'a mut (dyn FnMut(NodeId) + 'a)>,
    pub store_objects: Option<&'a mut (dyn Fn(&mut dyn Read<Error = Infallible>, usize) + 'a)>,
    pub reset_app: Option<&'a mut (dyn FnMut(&'a [ODEntry<'a>]) + 'a)>,
    pub reset_comms: Option<&'a mut (dyn FnMut(&'a [ODEntry<'a>]) + 'a)>,
    pub enter_operational: Option<&'a mut (dyn FnMut(&'a [ODEntry<'a>]) + 'a)>,
    pub enter_stopped: Option<&'a mut (dyn FnMut(&'a [ODEntry<'a>]) + 'a)>,
    pub enter_preoperational: Option<&'a mut (dyn FnMut(&'a [ODEntry<'a>]) + 'a)>,
}
Expand description

Collection of callbacks events which Node object can call.

Most are optional, and may be implemented by the application or not.

Fields§

§store_node_config: Option<&'a mut (dyn FnMut(NodeId) + 'a)>

Store node config to flash

An application should implement this callback in order to support storing a configured node ID persistently. It is triggered when the LSS StoreConfiguration command is received. The passed NodeId should be stored, and used when creating the Node object on the next boot.

§store_objects: Option<&'a mut (dyn Fn(&mut dyn Read<Error = Infallible>, usize) + 'a)>

Store object data to persistent flash

The bytes read from the provided reader (arg 1) should be stored. The total number of bytes in the stream is given in the second arg.

§reset_app: Option<&'a mut (dyn FnMut(&'a [ODEntry<'a>]) + 'a)>

The RESET_APP NMT state has been entered

If the application supported storing persistent object values, it should restore them now using the restore_stored_objects method. The application should also do whatever is appropraite to reset its state to it’s reset condition.

§reset_comms: Option<&'a mut (dyn FnMut(&'a [ODEntry<'a>]) + 'a)>

The RESET_COMMS NMT state has been entered

During RESET COMMS, communications objects (i.e. 0x1000-0x1fff) are reset to their boot up values. Application which store persistent object values should restore ONLY THE COMM OBJECTS now, using the restore_stored_comm_objects function.

This event will only be triggered by an NMT RESET_COMMS command – when a RESET_APP event occurs, only the reset_app callback is called.

§enter_operational: Option<&'a mut (dyn FnMut(&'a [ODEntry<'a>]) + 'a)>

The node is entering OPERATIONAL state

§enter_stopped: Option<&'a mut (dyn FnMut(&'a [ODEntry<'a>]) + 'a)>

The node is entering the STOPPED state

§enter_preoperational: Option<&'a mut (dyn FnMut(&'a [ODEntry<'a>]) + 'a)>

The node is entering the PRE-OPERATIONAL state

Implementations§

Source§

impl<'a> Callbacks<'a>

Source

pub const fn new() -> Self

Create a new Callbacks struct with the provided send_message callback

Trait Implementations§

Source§

impl<'a> Default for Callbacks<'a>

Source§

fn default() -> Callbacks<'a>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Callbacks<'a>

§

impl<'a> !RefUnwindSafe for Callbacks<'a>

§

impl<'a> !Send for Callbacks<'a>

§

impl<'a> !Sync for Callbacks<'a>

§

impl<'a> Unpin for Callbacks<'a>

§

impl<'a> !UnwindSafe for Callbacks<'a>

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.

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