Struct dbus::blocking::SyncConnection
source · [−]pub struct SyncConnection { /* private fields */ }
Expand description
A connection to D-Bus, Send + Sync + non-async version
Implementations
sourceimpl SyncConnection
impl SyncConnection
sourcepub fn new_session() -> Result<Self, Error>
pub fn new_session() -> Result<Self, Error>
Create a new connection to the session bus.
sourcepub fn new_system() -> Result<Self, Error>
pub fn new_system() -> Result<Self, Error>
Create a new connection to the system-wide bus.
sourcepub fn unique_name(&self) -> BusName<'_>
pub fn unique_name(&self) -> BusName<'_>
Get the connection’s unique name.
It’s usually something like “:1.54”
sourcepub fn with_proxy<'a, 'b, D: Into<BusName<'a>>, P: Into<Path<'a>>>(
&'b self,
dest: D,
path: P,
timeout: Duration
) -> Proxy<'a, &'b Self>
pub fn with_proxy<'a, 'b, D: Into<BusName<'a>>, P: Into<Path<'a>>>(
&'b self,
dest: D,
path: P,
timeout: Duration
) -> Proxy<'a, &'b Self>
Create a convenience struct for easier calling of many methods on the same destination and path.
sourcepub fn request_name<'a, N: Into<BusName<'a>>>(
&self,
name: N,
allow_replacement: bool,
replace_existing: bool,
do_not_queue: bool
) -> Result<RequestNameReply, Error>
pub fn request_name<'a, N: Into<BusName<'a>>>(
&self,
name: N,
allow_replacement: bool,
replace_existing: bool,
do_not_queue: bool
) -> Result<RequestNameReply, Error>
Request a name on the D-Bus.
For detailed information on the flags and return values, see the libdbus documentation.
sourcepub fn release_name<'a, N: Into<BusName<'a>>>(
&self,
name: N
) -> Result<ReleaseNameReply, Error>
pub fn release_name<'a, N: Into<BusName<'a>>>(
&self,
name: N
) -> Result<ReleaseNameReply, Error>
Release a previously requested name on the D-Bus.
sourcepub fn add_match<S: ReadAll, F>(
&self,
match_rule: MatchRule<'static>,
f: F
) -> Result<Token, Error> where
F: FnMut(S, &Self, &Message) -> bool + Send + Sync + 'static,
pub fn add_match<S: ReadAll, F>(
&self,
match_rule: MatchRule<'static>,
f: F
) -> Result<Token, Error> where
F: FnMut(S, &Self, &Message) -> bool + Send + Sync + 'static,
Adds a new match to the connection, and sets up a callback when this message arrives.
If multiple MatchRule
s match the same message, then by default only the first match will
get the callback. This behaviour can be changed for signal messages by calling
set_signal_match_mode
.
The returned value can be used to remove the match. The match is also removed if the callback returns “false”.
sourcepub fn add_match_no_cb(&self, match_str: &str) -> Result<(), Error>
pub fn add_match_no_cb(&self, match_str: &str) -> Result<(), Error>
Adds a new match to the connection, without setting up a callback when this message arrives.
sourcepub fn remove_match_no_cb(&self, match_str: &str) -> Result<(), Error>
pub fn remove_match_no_cb(&self, match_str: &str) -> Result<(), Error>
Removes a match from the connection, without removing any callbacks.
sourcepub fn remove_match(&self, id: Token) -> Result<(), Error>
pub fn remove_match(&self, id: Token) -> Result<(), Error>
Removes a previously added match and callback from the connection.
sourcepub fn set_signal_match_mode(&self, match_all: bool)
pub fn set_signal_match_mode(&self, match_all: bool)
If true, configures the connection to send signal messages to all matching MatchRule
filters added with add_match
rather than just the first one. This comes
with the following gotchas:
- The messages might be duplicated, so the message serial might be lost (this is generally not a problem for signals).
- Panicking inside a match callback might mess with other callbacks, causing them to be permanently dropped.
- Removing other matches from inside a match callback is not supported.
This is false by default, for a newly-created connection.
sourcepub fn process(&self, timeout: Duration) -> Result<bool, Error>
pub fn process(&self, timeout: Duration) -> Result<bool, Error>
Tries to handle an incoming message if there is one. If there isn’t one, it will wait up to timeout
This method only takes “&self” instead of “&mut self”, but it is a logic error to call it recursively and might lead to panics or deadlocks.
For SyncConnection
: It is also a logic error to call this method from one thread, while
calling this or other methods from other threads. This can lead to messages being lost.
Trait Implementations
sourceimpl BlockingSender for SyncConnection
impl BlockingSender for SyncConnection
sourceimpl From<Channel> for SyncConnection
impl From<Channel> for SyncConnection
sourcefn from(channel: Channel) -> SyncConnection
fn from(channel: Channel) -> SyncConnection
Converts to this type from the input type.
sourceimpl<S: ReadAll, F: FnMut(S, &SyncConnection, &Message) -> bool + Send + Sync + 'static> MakeSignal<Box<dyn FnMut(Message, &SyncConnection) + Send + Sync + 'static, Global>, S, SyncConnection> for F
impl<S: ReadAll, F: FnMut(S, &SyncConnection, &Message) -> bool + Send + Sync + 'static> MakeSignal<Box<dyn FnMut(Message, &SyncConnection) + Send + Sync + 'static, Global>, S, SyncConnection> for F
sourceimpl MatchingReceiver for SyncConnection
impl MatchingReceiver for SyncConnection
Auto Trait Implementations
impl RefUnwindSafe for SyncConnection
impl Send for SyncConnection
impl Sync for SyncConnection
impl Unpin for SyncConnection
impl UnwindSafe for SyncConnection
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more