1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! # Rustbus
//! Rustbus is a dbus library that allows for RPC on services on the bus or to implement your own service that listens on the bus. There are some examples
//! in the src/bin directory but the gist is:
//!
//! ```rust,no_run
//! use rustbus::{get_session_bus_path, standard_messages, Conn, Container, params::DictMap, MessageBuilder, client_conn::Timeout};
//!
//! fn main() -> Result<(), rustbus::client_conn::Error> {
//!     // Connect to the session bus
//!     let session_path = get_session_bus_path()?;
//!     let con = Conn::connect_to_bus(session_path, true)?;
//!
//!     // Wrap the con in an RpcConnection which provides many convenient functions
//!     let mut rpc_con = rustbus::client_conn::RpcConn::new(con);
//!
//!     // send the obligatory hello message
//!     rpc_con.send_message(&mut standard_messages::hello(), Timeout::Infinite)?;
//!
//!     // Request a bus name if you want to
//!     rpc_con.send_message(&mut standard_messages::request_name(
//!         "io.killing.spark".into(),
//!         0,
//!     ), Timeout::Infinite)?;
//!
//!     // send a signal to all bus members
//!     let mut sig = MessageBuilder::new()
//!     .signal(
//!         "io.killing.spark".into(),
//!         "TestSignal".into(),
//!         "/io/killing/spark".into(),
//!     )
//!     .build();
//!     
//!     sig.body.push_param("Signal message!").unwrap();
//!     rpc_con.send_message(&mut sig, Timeout::Infinite)?;
//!     Ok(())
//! }
//! ```

pub mod auth;
pub mod client_conn;
pub mod message;
pub mod message_builder;
pub mod params;
pub mod peer;
pub mod signature;
pub mod standard_messages;
pub mod wire;

// TODO create a rustbus::prelude

// needed to make own filters in RpcConn
pub use message::{Message, MessageType};

// needed to create a connection
pub use client_conn::{get_session_bus_path, get_system_bus_path, Conn, RpcConn};

// needed to make new messages
pub use message_builder::{CallBuilder, MessageBuilder, SignalBuilder};
pub use wire::marshal_trait::Marshal;

// needed for destructuring received messages
pub use params::{Base, Container, Param};

#[cfg(test)]
mod tests;