[](https://crates.io/crates/sylvia-iot-data)
[](https://docs.rs/sylvia-iot-data)

[](https://woofdogtw.github.io/sylvia-iot-core/coverage/sylvia-iot-data/)
[](https://hub.docker.com/r/woofdogtw/sylvia-iot-data)
[](LICENSE)
# sylvia-iot-data
The data storage of Sylvia-IoT core modules.
# Documentation
- [HTTP APIs](doc/api.md)
# Mount sylvia-iot-data in your axum App
You can simply mount sylvia-iot-data into your axum App:
```rust
use axum::Router;
use clap::App as ClapApp;
use std::net::SocketAddr;
use sylvia_iot_data::{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 data_state = match routes::new_state("/data", &conf).await {
Err(e) => {
println!("Error: {}", e);
return Ok(());
},
Ok(state) => state,
};
let app = Router::new().merge(routes::new_service(&data_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-data.rs`](src/bin/sylvia-iot-data.rs) to get the real world example.
## All-in-one binary
You can use [`src/bin/sylvia-iot-core.rs`](src/bin/sylvia-iot-core.rs) as a single binary to run the whole sylvia-iot platform.