Crates.io | sylvia-iot-coremgr |
lib.rs | sylvia-iot-coremgr |
version | 0.1.15 |
source | src |
created_at | 2023-03-05 15:08:43.613802 |
updated_at | 2024-09-27 12:15:02.317735 |
description | The manager of Sylvia-IoT core modules. |
homepage | |
repository | https://github.com/woofdogtw/sylvia-iot-core.git |
max_upload_size | |
id | 801501 |
size | 794,996 |
The manager of Sylvia-IoT core modules.
This module:
sylvia-iot-auth
and sylvia-iot-broker
.You can simply mount sylvia-iot-coremgr into your axum App:
use axum::Router;
use clap::App as ClapApp;
use std::net::SocketAddr;
use sylvia_iot_coremgr::{libs, routes};
use tokio::{self, net::TcpListener};
#[tokio::main]
async fn main() -> std::io::Result<()> {
let args = ClapApp::new("your-project-name").get_matches();
let conf = libs::config::read_args(&args);
let coremgr_state = match routes::new_state("/coremgr", &conf).await {
Err(e) => {
println!("Error: {}", e);
return Ok(());
},
Ok(state) => state,
};
let app = Router::new().merge(routes::new_service(&coremgr_state));
let listener = match TcpListener::bind("0.0.0.0:1080").await.unwrap();
axum::serve(listener, app.into_make_service_with_connect_info::<SocketAddr>()).await
}
Please see src/bin/sylvia-iot-coremgr.rs
to get the real world example.
You can use src/bin/sylvia-iot-core.rs
as a single binary to run the whole sylvia-iot platform.