Connection

Struct Connection 

Source
pub struct Connection { /* private fields */ }

Implementations§

Source§

impl Connection

Source

pub fn connect(addr: &str) -> Result<Connection, Error>

Connects to a DBus address string.

Source

pub fn connect_system() -> Result<Connection, Error>

Connects to the system bus.

The address is specified by the environment variable DBUS_SYSTEM_BUS_ADDRESS or “unix:path=/var/run/dbus/system_bus_socket” if unset.

Source

pub fn connect_session() -> Result<Connection, Error>

Connects to the session bus.

The address is specified by the environment variable DBUS_SESSION_BUS_ADDRESS.

Source

pub fn connect_uds<P: AsRef<Path>>(addr: P) -> Result<Connection, Error>

Creates a Connection object using a UNIX domain socket as the transport. The addr is the path to connect to. Abstract paths can be used by passing a NUL byte as the first byte of addr.

Source

pub fn connect_tcp<T: ToSocketAddrs>(addr: T) -> Result<Connection, Error>

Creates a Connection object using a TCP socket as the transport. The addr is the host and port to connect to.

Source

pub fn send(&self, mbuf: Message) -> Result<u32, Error>

Sends a message over the connection. The Message can be created by one of the functions from the message module, such as message::create_method_call . On success, returns the serial number of the outgoing message so that the reply can be identified.

Source

pub fn call_sync(&self, mbuf: Message) -> Result<Option<Vec<Value>>, Error>

Sends a message over a connection and block until a reply is received. This is only valid for method calls. Returns the sequence of Value objects that is the body of the method return.

§Panics

Calling this function with a Message for other than METHOD_CALL or with the NO_REPLY_EXPECTED flag set is a programming error and will panic.

Source

pub fn read_msg(&self) -> Result<Message, Error>

Blocks until a message comes in from the message bus. The received message is returned.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.