bffh/src/modules.rs

26 lines
776 B
Rust
Raw Normal View History

2020-02-14 12:20:17 +01:00
//! Indpendent Communication modules
//!
//! This is where dynamic modules are implemented later on using libloading / abi_stable_crates et
//! al.
//! Additionally, FFI modules to other languages (Python/Lua/...) make the most sense in here as
//! well.
use slog::Logger;
2020-09-14 10:37:51 +02:00
mod shelly;
use futures::prelude::*;
use futures::task::LocalSpawn;
2020-09-14 10:37:51 +02:00
2020-09-15 14:31:10 +02:00
use crate::config::Settings;
2020-09-14 10:37:51 +02:00
use crate::error::Result;
use crate::registries::Registries;
2020-09-14 10:37:51 +02:00
// spawner is a type that allows 'tasks' to be spawned on it, running them to completion.
2020-09-15 14:31:10 +02:00
pub fn init<S: LocalSpawn>(log: Logger, config: &Settings, spawner: &S, registries: Registries) -> Result<()> {
let f = Box::new(shelly::run(log.clone(), config.clone(), registries.clone()));
spawner.spawn_local_obj(f.into())?;
2020-09-14 10:37:51 +02:00
Ok(())
2020-02-14 12:20:17 +01:00
}