Struct libseat::SeatRef

source ·
pub struct SeatRef(_);

Implementations§

source§

impl SeatRef

source

pub fn disable(&mut self) -> Result<(), Errno>

Disables a seat, used in response to a disable_seat event. After disabling the seat, the seat devices must not be used until enable_seat is received, and all requests on the seat will fail during this period.

Examples found in repository?
examples/simple.rs (line 21)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
fn main() {
    let active = Rc::new(RefCell::new(false));

    let seat = {
        let active = active.clone();
        Seat::open(move |seat, event| match event {
            SeatEvent::Enable => {
                println!("Enable");
                println!("Name: {}", seat.name());

                *active.borrow_mut() = true;
            }
            SeatEvent::Disable => {
                println!("Disable");

                *active.borrow_mut() = false;
                seat.disable().unwrap();
            }
        })
    };

    if let Ok(mut seat) = seat {
        while !(*active.borrow()) {
            println!("waiting for activation...n");
            seat.dispatch(-1).unwrap();
        }

        // Close seat
        drop(seat);
    }
}
source

pub fn open_device<P: AsRef<Path>>(&mut self, path: &P) -> Result<Device, Errno>

Opens a device on the seat, returning its device ID and fd

This will only succeed if the seat is active and the device is of a type permitted for opening on the backend, such as drm and evdev.

The device may be revoked in some situations, such as in situations where a seat session switch is being forced.

source

pub fn close_device(&mut self, device: Device) -> Result<(), Errno>

Closes a device that has been opened on the seat using the device_id from libseat_open_device.

source

pub fn name(&mut self) -> &str

Retrieves the name of the seat that is currently made available through the provided libseat instance.

Examples found in repository?
examples/simple.rs (line 13)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
fn main() {
    let active = Rc::new(RefCell::new(false));

    let seat = {
        let active = active.clone();
        Seat::open(move |seat, event| match event {
            SeatEvent::Enable => {
                println!("Enable");
                println!("Name: {}", seat.name());

                *active.borrow_mut() = true;
            }
            SeatEvent::Disable => {
                println!("Disable");

                *active.borrow_mut() = false;
                seat.disable().unwrap();
            }
        })
    };

    if let Ok(mut seat) = seat {
        while !(*active.borrow()) {
            println!("waiting for activation...n");
            seat.dispatch(-1).unwrap();
        }

        // Close seat
        drop(seat);
    }
}
source

pub fn switch_session(&mut self, session: i32) -> Result<(), Errno>

Requests that the seat switches session to the specified session number. For seats that are VT-bound, the session number matches the VT number, and switching session results in a VT switch.

A call to libseat_switch_session does not imply that a switch will occur, and the caller should assume that the session continues unaffected.

source

pub fn get_fd(&mut self) -> Result<BorrowedFd<'_>, Errno>

Retrieve the pollable connection fd for a given libseat instance. Used to poll the libseat connection for events that need to be dispatched.

Returns a pollable fd on success.

source

pub fn dispatch(&mut self, timeout: i32) -> Result<i32, Errno>

Reads and dispatches events on the libseat connection fd.

The specified timeout dictates how long libseat might wait for data if none is available: 0 means that no wait will occur, -1 means that libseat might wait indefinitely for data to arrive, while > 0 is the maximum wait in milliseconds that might occur.

Returns a positive number signifying processed internal messages on success. Returns 0 if no messages were processed. Returns -1 and sets errno on error.

Examples found in repository?
examples/simple.rs (line 29)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
fn main() {
    let active = Rc::new(RefCell::new(false));

    let seat = {
        let active = active.clone();
        Seat::open(move |seat, event| match event {
            SeatEvent::Enable => {
                println!("Enable");
                println!("Name: {}", seat.name());

                *active.borrow_mut() = true;
            }
            SeatEvent::Disable => {
                println!("Disable");

                *active.borrow_mut() = false;
                seat.disable().unwrap();
            }
        })
    };

    if let Ok(mut seat) = seat {
        while !(*active.borrow()) {
            println!("waiting for activation...n");
            seat.dispatch(-1).unwrap();
        }

        // Close seat
        drop(seat);
    }
}

Trait Implementations§

source§

impl Debug for SeatRef

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.