[][src]Trait my_iot::services::Service

pub trait Service: Send {
    fn spawn(
        self: Box<Self>,
        db: Arc<Mutex<Db>>,
        tx: Sender<Reading>,
        rx: Receiver<Reading>
    ) -> Result<(), Error>; fn send(
        &self,
        tx: &Sender<Reading>,
        readings: Vec<Reading>
    ) -> Result<(), Error> { ... } }

A generic service.

Required methods

fn spawn(
    self: Box<Self>,
    db: Arc<Mutex<Db>>,
    tx: Sender<Reading>,
    rx: Receiver<Reading>
) -> Result<(), Error>

Spawn service threads.

Service may spawn as much threads as needed and must take care of their health.

  • db: database.
  • tx: 0-capacity channel sender.
  • rx: 0-capacity channel receiver.
Loading content...

Provided methods

fn send(
    &self,
    tx: &Sender<Reading>,
    readings: Vec<Reading>
) -> Result<(), Error>

Convenience function to send multiple readings at once.

Loading content...

Implementors

impl Service for Buienradar[src]

impl Service for Clock[src]

impl Service for Db[src]

impl Service for Nest[src]

Loading content...