#![warn(missing_docs)]
extern crate libc;
#[allow(missing_docs)]
extern crate libdbus_sys as ffi;
pub use crate::message::{Message, MessageType};
pub mod message;
pub mod ffidisp;
mod error;
pub use error::Error;
pub mod channel;
#[doc(hidden)]
pub mod crossroads;
pub mod blocking;
pub mod nonblock;
pub mod strings;
pub use crate::strings::{Signature, Path};
pub mod arg;
pub mod tree;
static INITDBUS: std::sync::Once = std::sync::ONCE_INIT;
use std::ffi::{CString, CStr};
use std::os::raw::c_char;
fn init_dbus() {
INITDBUS.call_once(|| {
if unsafe { ffi::dbus_threads_init_default() } == 0 {
panic!("Out of memory when trying to initialize D-Bus library!");
}
});
}
fn c_str_to_slice(c: & *const c_char) -> Option<&str> {
if c.is_null() { None }
else { std::str::from_utf8( unsafe { CStr::from_ptr(*c).to_bytes() }).ok() }
}
fn to_c_str(n: &str) -> CString { CString::new(n.as_bytes()).unwrap() }