Struct dbus::channel::Channel[][src]

pub struct Channel { /* fields omitted */ }

Low-level connection - handles read/write to the socket

You probably do not need to worry about this as you would typically use the various blocking and non-blocking "Connection" structs instead.

This version avoids dbus_connection_dispatch, and thus avoids callbacks from that function. Instead the same functionality is implemented in the various blocking and non-blocking "Connection" components.

Blocking operations are clearly marked as such, although if you try to access the connection from several threads at the same time, blocking might occur due to an internal mutex inside the dbus library.

Implementations

impl Channel[src]

pub fn get_private(bus: BusType) -> Result<Channel, Error>[src]

Creates a new D-Bus connection.

Blocking: until the connection is up and running.

pub fn open_private(address: &str) -> Result<Channel, Error>[src]

Creates a new D-Bus connection to a remote address.

Note: for all common cases (System / Session bus) you probably want "get_private" instead.

Blocking: until the connection is established.

pub fn register(&mut self) -> Result<(), Error>[src]

Registers a new D-Bus connection with the bus.

Note: get_private does this automatically, useful with open_private

Blocking: until a "Hello" response is received from the server.

pub fn is_connected(&self) -> bool[src]

Gets whether the connection is currently open.

pub fn unique_name(&self) -> Option<&str>[src]

Get the connection's unique name.

It's usually something like ":1.54"

pub fn send(&self, msg: Message) -> Result<u32, ()>[src]

Puts a message into libdbus out queue, and tries to send it.

Returns a serial number than can be used to match against a reply.

Note: usually the message is sent when this call happens, but in case internal D-Bus buffers are full, it will be left in the out queue. Call "flush" or "read_write" to retry flushing the out queue.

pub fn send_with_reply_and_block(
    &self,
    msg: Message,
    timeout: Duration
) -> Result<Message, Error>
[src]

Sends a message over the D-Bus and waits for a reply. This is used for method calls.

Blocking: until a reply is received or the timeout expires.

Note: In case of an error reply, this is returned as an Err(), not as a Ok(Message) with the error type.

Note: In case pop_message and send_with_reply_and_block is called in parallel from different threads, they might race to retreive the reply message from the internal queue.

pub fn flush(&self)[src]

Flush the queue of outgoing messages.

Blocking: until the outgoing queue is empty.

pub fn read_write(&self, timeout: Option<Duration>) -> Result<(), ()>[src]

Read and write to the connection.

Incoming messages are put in the internal queue, outgoing messages are written.

Blocking: If there are no messages, for up to timeout, or forever if timeout is None. For non-blocking behaviour, set timeout to Some(0).

pub fn has_messages_to_send(&self) -> bool[src]

Gets whether the output message buffer is non-empty

pub fn pop_message(&self) -> Option<Message>[src]

Removes a message from the incoming queue, or returns None if the queue is empty.

Use "read_write" first, so that messages are put into the incoming queue. For unhandled messages, please call MessageDispatcher::default_dispatch to return default replies for method calls.

pub fn blocking_pop_message(
    &self,
    timeout: Duration
) -> Result<Option<Message>, Error>
[src]

Removes a message from the incoming queue, or waits until timeout if the queue is empty.

pub fn set_watch_enabled(&mut self, enable: bool)[src]

Enables watch tracking, a prequisite for calling watch.

(In theory, this could panic in case libdbus ever changes to listen to something else than one file descriptor, but this should be extremely unlikely to ever happen.)

pub fn watch(&self) -> Watch[src]

Gets the file descriptor to listen for read/write.

Panics: if set_watch_enabled is false.

(In theory, this could panic in case libdbus ever changes to listen to something else than one file descriptor, but this should be extremely unlikely to ever happen.)

pub fn watch_fds(&mut self) -> Result<Vec<Watch>, ()>[src]

👎 Deprecated

Get an up-to-date list of file descriptors to watch.

Obsolete - in practice, you can use watch and set_watch_enabled instead.

Trait Implementations

impl AsRef<Channel> for Connection[src]

impl AsRef<Channel> for LocalConnection[src]

impl AsRef<Channel> for SyncConnection[src]

impl BlockingSender for Channel[src]

impl Debug for Channel[src]

impl Drop for Channel[src]

impl From<Channel> for Connection[src]

impl From<Channel> for LocalConnection[src]

impl From<Channel> for SyncConnection[src]

impl From<Channel> for Connection[src]

impl From<Channel> for LocalConnection[src]

impl From<Channel> for SyncConnection[src]

impl Sender for Channel[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.