Struct zbus::Proxy [−][src]
A client-side interface proxy.
A Proxy is a helper to interact with an interface on a remote object.
Example
use std::result::Result; use std::error::Error; use zbus::{Connection, Proxy}; fn main() -> Result<(), Box<dyn Error>> { let connection = Connection::new_session()?; let p = Proxy::new( &connection, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", )?; // owned return value let _id: String = p.call("GetId", &())?; // borrowed return value let _id: &str = p.call_method("GetId", &())?.body()?; Ok(()) }
Note
It is recommended to use the dbus_proxy macro, which provides a more convenient and
type-safe façade Proxy derived from a Rust trait.
Current limitations:
At the moment, Proxy doesn’t:
- cache properties
- track the current name owner
- prevent auto-launching
Implementations
impl<'a> Proxy<'a>[src]
pub fn new<E>(
conn: &Connection,
destination: &'a str,
path: impl TryInto<ObjectPath<'a>, Error = E>,
interface: &'a str
) -> Result<Self> where
Error: From<E>, [src]
conn: &Connection,
destination: &'a str,
path: impl TryInto<ObjectPath<'a>, Error = E>,
interface: &'a str
) -> Result<Self> where
Error: From<E>,
Create a new Proxy for the given destination/path/interface.
pub fn new_owned<E>(
conn: Connection,
destination: String,
path: impl TryInto<ObjectPath<'static>, Error = E>,
interface: String
) -> Result<Self> where
Error: From<E>, [src]
conn: Connection,
destination: String,
path: impl TryInto<ObjectPath<'static>, Error = E>,
interface: String
) -> Result<Self> where
Error: From<E>,
Create a new Proxy for the given destination/path/interface, taking ownership of all
passed arguments.
pub fn connection(&self) -> &Connection[src]
Get a reference to the associated connection.
pub fn destination(&self) -> &str[src]
Get a reference to the destination service name.
pub fn path(&self) -> &ObjectPath<'_>[src]
Get a reference to the object path.
pub fn interface(&self) -> &str[src]
Get a reference to the interface.
pub fn introspect(&self) -> Result<String>[src]
Introspect the associated object, and return the XML description.
See the xml module for parsing the result.
pub fn get_property<T>(&self, property_name: &str) -> Result<T> where
T: TryFrom<OwnedValue>, [src]
T: TryFrom<OwnedValue>,
Get the property property_name.
Effectively, call the Get method of the org.freedesktop.DBus.Properties interface.
pub fn set_property<'t, T: 't>(
&self,
property_name: &str,
value: T
) -> Result<()> where
T: Into<Value<'t>>, [src]
&self,
property_name: &str,
value: T
) -> Result<()> where
T: Into<Value<'t>>,
Set the property property_name.
Effectively, call the Set method of the org.freedesktop.DBus.Properties interface.
pub fn call_method<B>(&self, method_name: &str, body: &B) -> Result<Message> where
B: Serialize + Type, [src]
B: Serialize + Type,
Call a method and return the reply.
Typically, you would want to use call method instead. Use this method if you need to
deserialize the reply message manually (this way, you can avoid the memory
allocation/copying, by deserializing the reply to an unowned type).
pub fn call<B, R>(&self, method_name: &str, body: &B) -> Result<R> where
B: Serialize + Type,
R: DeserializeOwned + Type, [src]
B: Serialize + Type,
R: DeserializeOwned + Type,
Call a method and return the reply body.
Use call_method instead if you need to deserialize the reply manually/separately.
pub fn connect_signal<H>(
&self,
signal_name: &'static str,
handler: H
) -> Result<SignalHandlerId> where
H: FnMut(&Message) -> Result<()> + Send + 'static, [src]
&self,
signal_name: &'static str,
handler: H
) -> Result<SignalHandlerId> where
H: FnMut(&Message) -> Result<()> + Send + 'static,
Register a handler for signal named signal_name.
Once a handler is successfully registered, call Self::next_signal to wait for the next
signal to arrive and be handled by its registered handler. A unique ID for the handler is
returned, which can be used to deregister this handler using Self::disconnect_signal
method.
Errors
This method can fail if addition of the relevant match rule on the bus fails. You can
safely unwrap the Result if you’re certain that associated connnection is not a bus
connection.
pub fn disconnect_signal(&self, handler_id: SignalHandlerId) -> Result<bool>[src]
Deregister the signal handler with the ID handler_id.
This method returns Ok(true) if a handler with the id handler_id is found and removed;
Ok(false) otherwise.
Errors
This method can fail if removal of the relevant match rule on the bus fails. You can
safely unwrap the Result if you’re certain that associated connnection is not a bus
connection.
pub fn next_signal(&self) -> Result<Option<Message>>[src]
Receive and handle the next incoming signal on the associated connection.
This method will wait for signal messages on the associated connection and call any
handlers registered through the Self::connect_signal method. Signal handlers can be
registered and deregistered from another threads during the call to this method.
If the signal message was handled by a handler, Ok(None) is returned. Otherwise, the
received message is returned.
Errors
Apart from general I/O errors that can result from socket communications, calling this method will also result in an error if the destination service has not yet registered its well-known name with the bus (assuming you’re using the well-known name as destination).
pub fn handle_signal(&self, msg: &Message) -> Result<bool>[src]
Handle the provided signal message.
Call any handlers registered through the Self::connect_signal method for the provided
signal message.
If no errors are encountered, Ok(true) is returned if a handler was found and called for,
the signal; Ok(false) otherwise.
pub fn inner(&self) -> &Proxy<'_>[src]
Get a reference to the underlying async Proxy.
pub fn into_inner(self) -> Proxy<'a>[src]
Get the underlying async Proxy, consuming self.
Trait Implementations
impl<'c> AsMut<Proxy<'c>> for IntrospectableProxy<'c>[src]
impl<'c> AsMut<Proxy<'c>> for PropertiesProxy<'c>[src]
impl<'c> AsMut<Proxy<'c>> for ObjectManagerProxy<'c>[src]
impl<'c> AsMut<Proxy<'c>> for PeerProxy<'c>[src]
impl<'c> AsMut<Proxy<'c>> for MonitoringProxy<'c>[src]
impl<'c> AsMut<Proxy<'c>> for StatsProxy<'c>[src]
impl<'c> AsMut<Proxy<'c>> for DBusProxy<'c>[src]
impl<'asref, 'p: 'asref> AsRef<Proxy<'asref>> for Proxy<'p>[src]
impl<'c> AsRef<Proxy<'c>> for IntrospectableProxy<'c>[src]
impl<'c> AsRef<Proxy<'c>> for PropertiesProxy<'c>[src]
impl<'c> AsRef<Proxy<'c>> for ObjectManagerProxy<'c>[src]
impl<'c> AsRef<Proxy<'c>> for PeerProxy<'c>[src]
impl<'c> AsRef<Proxy<'c>> for MonitoringProxy<'c>[src]
impl<'c> AsRef<Proxy<'c>> for StatsProxy<'c>[src]
impl<'c> AsRef<Proxy<'c>> for DBusProxy<'c>[src]
impl<'a> Debug for Proxy<'a>[src]
impl<'p, 'a: 'p> From<Proxy<'a>> for Proxy<'p>[src]
impl<'azync, 'sync: 'azync> From<Proxy<'sync>> for Proxy<'azync>[src]
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Proxy<'a>
impl<'a> Send for Proxy<'a>
impl<'a> Sync for Proxy<'a>
impl<'a> Unpin for Proxy<'a>
impl<'a> !UnwindSafe for Proxy<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,