[]Struct gio::DBusServer

pub struct DBusServer(_, _);

DBusServer is a helper for listening to and accepting D-Bus connections. This can be used to create a new D-Bus server, allowing two peers to use the D-Bus protocol for their own specialized communication. A server instance provided in this way will not perform message routing or implement the org.freedesktop.DBus interface.

To just export an object on a well-known name on a message bus, such as the session or system bus, you should instead use g_bus_own_name.

An example of peer-to-peer communication with G-DBus can be found in gdbus-example-peer.c.

Note that a minimal DBusServer will accept connections from any peer. In many use-cases it will be necessary to add a DBusAuthObserver that only accepts connections that have successfully authenticated as the same user that is running the DBusServer.

Implements

glib::object::ObjectExt

Implementations

impl DBusServer[src]

pub fn new_sync<P: IsA<Cancellable>>(
    address: &str,
    flags: DBusServerFlags,
    guid: &str,
    observer: Option<&DBusAuthObserver>,
    cancellable: Option<&P>
) -> Result<DBusServer, Error>
[src]

Creates a new D-Bus server that listens on the first address in address that works.

Once constructed, you can use DBusServer::get_client_address to get a D-Bus address string that clients can use to connect.

To have control over the available authentication mechanisms and the users that are authorized to connect, it is strongly recommended to provide a non-None DBusAuthObserver.

Connect to the DBusServer::new-connection signal to handle incoming connections.

The returned DBusServer isn't active - you have to start it with DBusServer::start.

DBusServer is used in this [example][gdbus-peer-to-peer].

This is a synchronous failable constructor. There is currently no asynchronous version.

address

A D-Bus address.

flags

Flags from the DBusServerFlags enumeration.

guid

A D-Bus GUID.

observer

A DBusAuthObserver or None.

cancellable

A Cancellable or None.

Returns

A DBusServer or None if error is set. Free with gobject::ObjectExt::unref.

pub fn get_client_address(&self) -> Option<GString>[src]

Gets a D-Bus address string that can be used by clients to connect to self.

Returns

A D-Bus address string. Do not free, the string is owned by self.

pub fn get_flags(&self) -> DBusServerFlags[src]

Gets the flags for self.

Returns

A set of flags from the DBusServerFlags enumeration.

pub fn get_guid(&self) -> Option<GString>[src]

Gets the GUID for self.

Returns

A D-Bus GUID. Do not free this string, it is owned by self.

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

Gets whether self is active.

Returns

true if server is active, false otherwise.

pub fn start(&self)[src]

Starts self.

pub fn stop(&self)[src]

Stops self.

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

Whether the server is currently active.

pub fn get_property_address(&self) -> Option<GString>[src]

The D-Bus address to listen on.

pub fn get_property_authentication_observer(&self) -> Option<DBusAuthObserver>[src]

A DBusAuthObserver object to assist in the authentication process or None.

pub fn connect_new_connection<F: Fn(&DBusServer, &DBusConnection) -> bool + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

Emitted when a new authenticated connection has been made. Use DBusConnection::get_peer_credentials to figure out what identity (if any), was authenticated.

If you want to accept the connection, take a reference to the connection object and return true. When you are done with the connection call DBusConnection::close and give up your reference. Note that the other peer may disconnect at any time - a typical thing to do when accepting a connection is to listen to the DBusConnection::closed signal.

If DBusServer:flags contains DBusServerFlags::RunInThread then the signal is emitted in a new thread dedicated to the connection. Otherwise the signal is emitted in the [thread-default main context][g-main-context-push-thread-default] of the thread that server was constructed in.

You are guaranteed that signal handlers for this signal runs before incoming messages on connection are processed. This means that it's suitable to call DBusConnection::register_object or similar from the signal handler.

connection

A DBusConnection for the new connection.

Returns

true to claim connection, false to let other handlers run.

pub fn connect_property_active_notify<F: Fn(&DBusServer) + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

pub fn connect_property_client_address_notify<F: Fn(&DBusServer) + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

Trait Implementations

impl Clone for DBusServer

impl Debug for DBusServer

impl Display for DBusServer[src]

impl Eq for DBusServer

impl Hash for DBusServer

impl Ord for DBusServer

impl<T: ObjectType> PartialEq<T> for DBusServer

impl<T: ObjectType> PartialOrd<T> for DBusServer

impl StaticType for DBusServer

Auto Trait Implementations

impl RefUnwindSafe for DBusServer

impl !Send for DBusServer

impl !Sync for DBusServer

impl Unpin for DBusServer

impl UnwindSafe for DBusServer

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<Super, Sub> CanDowncast<Sub> for Super where
    Sub: IsA<Super>,
    Super: IsA<Super>, 

impl<T> Cast for T where
    T: ObjectType, 

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

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

impl<T> ObjectExt for T where
    T: ObjectType, 

impl<'a, T> ToGlibContainerFromSlice<'a, *const GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *const GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<PtrArray>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<Array>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<PtrArray>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToSendValue for T where
    T: ToValue + SetValue + Send + ?Sized

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> ToValue for T where
    T: SetValue + ?Sized

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.