Initialize all the stuff

...like D-Bus connection to system bus, env_logger, and tokio
This commit is contained in:
Elias Schriefer 2020-08-30 16:41:59 +02:00
parent e6ffb3f3e1
commit 41ca57898d

28
sfsmcctl/src/main.rs Normal file
View File

@ -0,0 +1,28 @@
use log::{ debug, info, warn, error };
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// env_logger initialization
// If running with debug profile and `RUST_LOG` environment variable isn't set, set it to "debug"
if cfg!(debug_assertions) && std::env::var_os(env_logger::DEFAULT_FILTER_ENV).is_none() {
std::env::set_var(env_logger::DEFAULT_FILTER_ENV, "debug");
}
env_logger::init();
// TODO: use clap
// Connect with D-Bus
let (resource, c) = dbus_tokio::connection::new_system_sync()?;
debug!("D-Bus unique name: {}", c.unique_name());
// Spawn a new task for the D-Bus resource
tokio::spawn(async move {
let err = resource.await;
panic!("Lost connection to D-Bus: {}", err);
});
// TODO:
// Perform operations
Ok(())
}