Struct DBusSource

Source
pub struct DBusSource<Data: 'static> { /* private fields */ }
Expand description

A event source connection to D-Bus, non-async version where callbacks are Send but not Sync.

Implementations§

Source§

impl<Data> DBusSource<Data>

Source

pub fn new_session() -> Result<(Self, Sender<Message>)>

Create a new connection to the session bus.

Source

pub fn new_system() -> Result<(Self, Sender<Message>)>

Create a new connection to the system-wide bus.

Source

pub fn unique_name(&self) -> BusName<'_>

Get the connection’s unique name.

It’s usually something like “:1.54”

Source

pub fn with_proxy<'a, 'b, Dest: Into<BusName<'a>>, BusPath: Into<Path<'a>>>( &'b self, dest: Dest, path: BusPath, timeout: Duration, ) -> Proxy<'a, &'b Self>

Source

pub fn request_name<'a, Name: Into<BusName<'a>>>( &self, name: Name, 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.

Source

pub fn release_name<'a, Name: Into<BusName<'a>>>( &self, name: Name, ) -> Result<ReleaseNameReply, Error>

Release a previously requested name on the D-Bus.

Source

pub fn add_match<Args: ReadAll, Callback>( &self, match_rule: MatchRule<'static>, callback: Callback, ) -> Result<Token, Error>
where Callback: FnMut(Args, &Self, &Message) -> bool + Send + 'static,

Adds a new match to the connection, and sets up a callback when this message arrives.

The returned value can be used to remove the match. The match is also removed if the callback returns “false”.

Source

pub fn add_match_data<Args: ReadAll, Callback>( &self, match_rule: MatchRule<'static>, callback: Callback, ) -> Result<Token, Error>
where Callback: FnMut(Args, &Self, &Message, &mut Data) -> bool + Send + 'static,

Adds a new match to the connection, and sets up a callback when this message arrives. This callback will be able to access the calloop user data.

The returned value can be used to remove the match. The match is also removed if the callback returns “false”.

Source

pub fn remove_match(&self, id: Token) -> Result<(), Error>

Removes a previously added match and callback from the connection.

Source

pub fn process(&mut self, timeout: Duration) -> Result<bool, Error>

Source

pub fn channel(&self) -> &Channel

The Channel for this connection

Source

pub fn quick_insert( self, handle: LoopHandle<Data>, panic_on_orphan: bool, ) -> Result<Source<DBusSource<Data>>, InsertError<DBusSource<Data>>>

Insert this source into the given event loop with an adapder that ether panics on orphan events or just logs it at warn level. You probably only what this if you set eavesdrop on a MatchRule.

Trait Implementations§

Source§

impl<Data> BlockingSender for DBusSource<Data>

Source§

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

Sends a message over the D-Bus and blocks, waiting for a reply or a timeout. This is used for method calls. Read more
Source§

impl<Data> EventSource for DBusSource<Data>

Source§

type Event = Message

The type of events generated by your source.
Source§

type Metadata = DBusSource<Data>

Some metadata of your event source Read more
Source§

type Ret = Option<Token>

The return type of the user callback Read more
Source§

fn process_events<Callback>( &mut self, readiness: Readiness, token: Token, callback: Callback, ) -> Result<()>
where Callback: FnMut(Self::Event, &mut Self::Metadata) -> Self::Ret,

Process any relevant events Read more
Source§

fn register(&mut self, poll: &mut Poll, token: Token) -> Result<()>

Register yourself to this poll instance Read more
Source§

fn reregister(&mut self, poll: &mut Poll, token: Token) -> Result<()>

Re-register your file descriptors Read more
Source§

fn unregister(&mut self, poll: &mut Poll) -> Result<()>

Unregister your file descriptors Read more
Source§

impl<Args: ReadAll, Callback: FnMut(Args, &DBusSource<Data>, &Message, &mut Data) -> bool + Send + 'static, Data> MakeDataSignal<Box<dyn FnMut(Message, &DBusSource<Data>, &mut Data) -> bool + Send>, Args, DBusSource<Data>> for Callback

Source§

fn make( self, match_str: String, ) -> Box<dyn FnMut(Message, &DBusSource<Data>, &mut Data) -> bool + Send + 'static>

Internal helper trait
Source§

impl<Args: ReadAll, Callback: FnMut(Args, &DBusSource<Data>, &Message) -> bool + Send + 'static, Data> MakeSignal<Box<dyn FnMut(Message, &DBusSource<Data>, &mut Data) -> bool + Send>, Args, DBusSource<Data>> for Callback

Source§

fn make( self, match_str: String, ) -> Box<dyn FnMut(Message, &DBusSource<Data>, &mut Data) -> bool + Send + 'static>

Internal helper trait
Source§

impl<Data> MatchingReceiver for DBusSource<Data>

Source§

type F = Box<dyn FnMut(Message, &DBusSource<Data>, &mut Data) -> bool + Send>

Type of callback
Source§

fn start_receive( &self, match_rule: MatchRule<'static>, callback: Self::F, ) -> Token

Add a callback to be called in case a message matches. Read more
Source§

fn stop_receive(&self, id: Token) -> Option<(MatchRule<'static>, Self::F)>

Remove a previously added callback.
Source§

impl<Data> Sender for DBusSource<Data>

Source§

fn send(&self, msg: Message) -> Result<u32, ()>

Schedules a message for sending. Read more

Auto Trait Implementations§

§

impl<Data> !Freeze for DBusSource<Data>

§

impl<Data> !RefUnwindSafe for DBusSource<Data>

§

impl<Data> Send for DBusSource<Data>

§

impl<Data> !Sync for DBusSource<Data>

§

impl<Data> Unpin for DBusSource<Data>

§

impl<Data> !UnwindSafe for DBusSource<Data>

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.