Coverage Report

Created: 2025-12-28 06:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/dbus-0.9.7/src/lib.rs
Line
Count
Source
1
//! D-Bus bindings for Rust
2
//!
3
//! [D-Bus](http://dbus.freedesktop.org/) is a message bus, and is mainly used in Linux
4
//! for communication between processes. It is present by default on almost every
5
//! Linux distribution out there, and runs in two instances - one per session, and one
6
//! system-wide.
7
//!
8
//! In addition to the API documentation, which you're currently reading, you might want to
9
//! look in the examples directory, which contains many examples and some additional documents.
10
//! README.md also contains a few quick "getting started" examples (as well as information about
11
//! the `futures` and `no-string-validation` features).
12
//!
13
//! In addition to this crate, there are some companion crates:
14
//!  * dbus-tokio for integrating D-Bus with [Tokio](http://tokio.rs)
15
//!  * dbus-codegen for generating code from D-Bus introspection data
16
//!  * libdbus-sys contains the raw bindings to the C libdbus library.
17
18
#![warn(missing_docs)]
19
20
extern crate libc;
21
22
#[allow(missing_docs)]
23
extern crate libdbus_sys as ffi;
24
25
pub use crate::message::{Message, MessageType};
26
27
pub mod message;
28
29
pub mod ffidisp;
30
31
mod error;
32
pub use error::{Error, MethodErr};
33
34
pub mod channel;
35
36
mod filters;
37
38
pub mod blocking;
39
40
#[cfg(feature = "futures")]
41
pub mod nonblock;
42
43
pub mod strings;
44
pub use crate::strings::{Signature, Path};
45
46
pub mod arg;
47
48
// pub mod tree;
49
50
static INITDBUS: std::sync::Once = std::sync::Once::new();
51
52
use std::ffi::{CString, CStr};
53
use std::os::raw::c_char;
54
55
0
fn init_dbus() {
56
0
    INITDBUS.call_once(|| {
57
0
        if unsafe { ffi::dbus_threads_init_default() } == 0 {
58
0
            panic!("Out of memory when trying to initialize D-Bus library!");
59
0
        }
60
0
    });
61
0
}
62
63
0
fn c_str_to_slice(c: & *const c_char) -> Option<&str> {
64
0
    if c.is_null() { None }
65
0
    else { std::str::from_utf8( unsafe { CStr::from_ptr(*c).to_bytes() }).ok() }
66
0
}
67
68
0
fn to_c_str(n: &str) -> CString { CString::new(n.as_bytes()).unwrap() }