Struct logind_zbus::SessionProxy[][src]

pub struct SessionProxy<'a>(_);

Proxy wrapper for the logind Session dbus interface

All get_* methods are property getters

Example

use logind_zbus::ManagerProxy;
use logind_zbus::SessionProxy;
use zbus::Connection;

let connection = Connection::new_system().unwrap();
let manager = ManagerProxy::new(&connection).unwrap();
let sessions = manager.list_sessions().unwrap();
let session = SessionProxy::new(&connection, &sessions[0]).unwrap();

let time1 = session.get_timestamp().unwrap();
assert!(time1.as_secs() > 0);

let time2 = session.get_timestamp_monotonic().unwrap();
assert!(time2.as_secs() > 0);

Notes

All connect_* functions are signals and each of these functions names reflect the underlying generated Proxy call. If desired the wrapped function can be bypassed with:

*<SessionProxy>.connect_<function name>()

Implementations

impl<'a> SessionProxy<'a>[src]

pub fn new<S>(connection: &Connection, session: &'a S) -> Result<Self> where
    S: IntoSessionPath
[src]

pub fn get_proxy(&self) -> &SessionProxy<'_>[src]

Borrow the underlying SessionProxy for use with zbus directly

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.

pub fn activate(&self) -> Result<()>[src]

Bring session to foreground

pub fn kill(&self, who: UserPath, signal: i32) -> Result<()>[src]

Send a signal to all processes of the user

pub fn lock(&self) -> Result<()>[src]

Ask session to activate its screen lock

pub fn pause_device_complete(&self, major: u32, minor: u32) -> Result<()>[src]

Allows a session controller to synchronously pause a device after receiving a PauseDevice(“pause”) signal

pub fn release_control(&self) -> Result<()>[src]

Drops control of a given session. Closing the D-Bus connection implicitly releases control as well. This method also releases all devices for which the controller requested

pub fn release_device(&self, major: u32, minor: u32) -> Result<()>[src]

Release a device (after TakeDevice). This is also implicitly done by release_control() or when closing the D-Bus connection.

pub fn set_brightness(
    &self,
    subsystem: &str,
    name: &str,
    brightness: u32
) -> Result<()>
[src]

Used to set the display brightness. This is intended to be used by the desktop environment and allows unprivileged programs to access hardware settings in a controlled way.

pub fn set_idle_hint(&self, idle: bool) -> Result<()>[src]

SetIdleHint() is called by the session object to update the idle state of the session whenever it changes

pub fn set_locked_hint(&self, locked: bool) -> Result<()>[src]

pub fn set_type(&self, type_: &str) -> Result<()>[src]

Allows the type of the session to be changed dynamically. It can only be called by session’s current controller. If take_control() has not been called, this method will fail. In addition, the session type will be reset to its original value once control is released, either by calling release_control() or closing the D-Bus connection.

pub fn take_control(&self, force: bool) -> Result<()>[src]

Allows a process to take exclusive managed device access-control for that session

pub fn take_device(&self, major: u32, minor: u32) -> Result<Device>[src]

Get a file descriptor for a specific device. Pass in the major and minor numbers of the character device and systemd-logind will return a file descriptor for the device.

pub fn terminate(&self) -> Result<()>[src]

Forcibly terminate this session

pub fn unlock(&self) -> Result<()>[src]

Ask this session to deactivate its lock screen

pub fn get_active(&self) -> Result<bool>[src]

Property: Is session is active, i.e. currently in the foreground. This field is semi-redundant due to State (get_state()).

pub fn get_audit(&self) -> Result<u32>[src]

Property: the Kernel Audit session ID of the session if auditing is available.

pub fn get_class(&self) -> Result<SessionClass>[src]

Property: The class of Session

pub fn get_desktop(&self) -> Result<String>[src]

Property: Describes the desktop environment running in the session (if known)

pub fn get_display(&self) -> Result<String>[src]

The X11 display name if this is a graphical login. If not, this is an empty string.

pub fn get_id(&self) -> Result<String>[src]

Property: Session ID

pub fn get_is_idle_hint(&self) -> Result<bool>[src]

pub fn get_is_idle_since_hint(&self) -> Result<u64>[src]

pub fn get_is_idle_since_hint_monotonic(&self) -> Result<u64>[src]

pub fn get_leader(&self) -> Result<u32>[src]

Property: PID of the process that registered the session

pub fn get_locked_hint(&self) -> Result<bool>[src]

Property: shows the locked hint state of this session

pub fn get_name(&self) -> Result<String>[src]

Property: The User name

pub fn get_is_remote(&self) -> Result<bool>[src]

Property: local or remote

pub fn get_remote_host(&self) -> Result<Option<String>>[src]

Property: None if not remote

pub fn get_remote_user(&self) -> Result<Option<String>>[src]

Property: None if not remote

pub fn get_scope(&self) -> Result<String>[src]

Property: systemd scope unit name of this session

pub fn get_seat(&self) -> Result<SeatPath>[src]

Property: seat this session belongs to if there is any

pub fn get_service(&self) -> Result<String>[src]

Property: PAM service name that registered the session

pub fn get_state(&self) -> Result<SessionState>[src]

Property: State of the session

pub fn get_tty(&self) -> Result<Option<String>>[src]

Property: kernel TTY path of the session if this is a text login. If not this None.

pub fn get_timestamp(&self) -> Result<Duration>[src]

Property: Get time since session was created (realtime)

pub fn get_timestamp_monotonic(&self) -> Result<Duration>[src]

Property: Get time since session was created (wal time)

pub fn get_type(&self) -> Result<SessionType>[src]

Property: Session type

pub fn get_user(&self) -> Result<UserPath>[src]

Property: User the session belongs to

pub fn get_vtnr(&self) -> Result<u32>[src]

Property: Virtual terminal number of the session if there is any, 0 otherwise.

pub fn connect_lock<C>(&self, callback: C) -> Result<SignalHandlerId> where
    C: FnMut() -> Result<(), Error> + Send + 'static, 
[src]

pub fn connect_pause_device<C>(&self, callback: C) -> Result<SignalHandlerId> where
    C: FnMut(u32, u32, &str) -> Result<(), Error> + Send + 'static, 
[src]

pub fn connect_resume_device<C>(&self, callback: C) -> Result<SignalHandlerId> where
    C: FnMut(u32, u32, i32) -> Result<(), Error> + Send + 'static, 
[src]

pub fn connect_unlock<C>(&self, callback: C) -> Result<SignalHandlerId> where
    C: FnMut() -> Result<(), Error> + Send + 'static, 
[src]

Methods from Deref<Target = Proxy<'a>>

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, Error>[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, Error> where
    T: TryFrom<OwnedValue>, 
[src]

Get the property property_name.

Effectively, call the Get method of the org.freedesktop.DBus.Properties interface.

pub fn set_property<'t, T>(
    &self,
    property_name: &str,
    value: T
) -> Result<(), Error> where
    T: 't + Into<Value<'t>>, 
[src]

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, Error> where
    B: Serialize + Type
[src]

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, Error> where
    B: Serialize + Type,
    R: DeserializeOwned + Type
[src]

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, Error> where
    H: FnMut(&Message) -> Result<(), Error> + Send + 'static, 
[src]

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, Error>
[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>, Error>[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, Error>[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.

Trait Implementations

impl<'a> AsMut<Proxy<'a>> for SessionProxy<'a>[src]

impl<'a> AsRef<Proxy<'a>> for SessionProxy<'a>[src]

impl<'a> Deref for SessionProxy<'a>[src]

type Target = Proxy<'a>

The resulting type after dereferencing.

impl<'a> DerefMut for SessionProxy<'a>[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for SessionProxy<'a>

impl<'a> Send for SessionProxy<'a>

impl<'a> Sync for SessionProxy<'a>

impl<'a> Unpin for SessionProxy<'a>

impl<'a> !UnwindSafe for SessionProxy<'a>

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<T> From<T> for T[src]

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

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,