pub struct Proxy<'a, C> {
pub destination: BusName<'a>,
pub path: Path<'a>,
pub timeout: Duration,
pub connection: C,
}Expand description
A struct that wraps a connection, destination and path.
A D-Bus “Proxy” is a client-side object that corresponds to a remote object on the server side. Calling methods on the proxy object calls methods on the remote object. Read more in the D-Bus tutorial
Fields§
§destination: BusName<'a>Destination, i e what D-Bus service you’re communicating with
path: Path<'a>Object path on the destination
timeout: DurationTimeout for method calls
connection: CSome way to send and/or receive messages, either blocking or non-blocking.
Implementations§
Source§impl<'a, T: BlockingSender, C: Deref<Target = T>> Proxy<'a, C>
impl<'a, T: BlockingSender, C: Deref<Target = T>> Proxy<'a, C>
Sourcepub fn method_call<'i, 'm, R: ReadAll, A: AppendAll, I: Into<Interface<'i>>, M: Into<Member<'m>>>(
&self,
i: I,
m: M,
args: A,
) -> Result<R, Error>
pub fn method_call<'i, 'm, R: ReadAll, A: AppendAll, I: Into<Interface<'i>>, M: Into<Member<'m>>>( &self, i: I, m: M, args: A, ) -> Result<R, Error>
Make a method call using typed input and output arguments, then block waiting for a reply.
§Example
use dbus::blocking::{Connection, Proxy};
let conn = Connection::new_session()?;
let proxy = Proxy::new("org.freedesktop.DBus", "/", std::time::Duration::from_millis(5000), &conn);
let (has_owner,): (bool,) = proxy.method_call("org.freedesktop.DBus", "NameHasOwner", ("dummy.name.without.owner",))?;
assert_eq!(has_owner, false);Sourcepub fn match_start(
&self,
mr: MatchRule<'static>,
call_add_match: bool,
f: <T as MatchingReceiver>::F,
) -> Result<Token, Error>where
T: MatchingReceiver,
pub fn match_start(
&self,
mr: MatchRule<'static>,
call_add_match: bool,
f: <T as MatchingReceiver>::F,
) -> Result<Token, Error>where
T: MatchingReceiver,
Starts matching incoming messages on this destination and path.
For matching signals, match_signal might be more convenient.
The match rule will be modified to include this path and destination only.
If call_add_match is true, will notify the D-Bus server that matching should start.
Sourcepub fn match_stop(
&self,
id: Token,
call_remove_match: bool,
) -> Result<(), Error>where
T: MatchingReceiver,
pub fn match_stop(
&self,
id: Token,
call_remove_match: bool,
) -> Result<(), Error>where
T: MatchingReceiver,
Stops matching a signal added with match_start or match_signal.
If call_remove_match is true, will notify the D-Bus server that matching should stop, this should be true in case match_signal was used.
Sourcepub fn match_signal<S: SignalArgs + ReadAll, F>(
&self,
f: F,
) -> Result<Token, Error>
pub fn match_signal<S: SignalArgs + ReadAll, F>( &self, f: F, ) -> Result<Token, Error>
Sets up an incoming signal match, that calls the supplied callback every time the signal is received.
It takes a callback of the format |SignalStruct, &Connection, &Message| where SignalStruct is a struct
which implements SignalArgs and ReadAll (which signal structs generated by dbus-codegen typically do).
See the signal_match example.
The returned value can be used to remove the match. The match is also removed if the callback returns “false”.