1use crate::protocol::Interface;
23/// Description of a global advertised to some clients.
4#[derive(Debug)]
5pub struct GlobalInfo {
6/// The interface of the global.
7pub interface: &'static Interface,
8/// The version of the global that is advertised to clients.
9pub version: u32,
10/// Whether the global is disabled.
11pub disabled: bool,
12}
1314/// An error type representing the failure to initialize a backend
15#[derive(Debug)]
16pub enum InitError {
17/// The wayland system library could not be loaded
18NoWaylandLib,
19/// Initialized failed due to an underlying I/O error
20Io(std::io::Error),
21}
2223impl std::error::Error for InitError {
24#[cfg_attr(coverage, coverage(off))]
25fn cause(&self) -> Option<&dyn std::error::Error> {
26match self {
27 InitError::Io(ref err) => Some(err),
28 InitError::NoWaylandLib => None,
29 }
30 }
31}
3233impl std::fmt::Display for InitError {
34#[cfg_attr(coverage, coverage(off))]
35fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
36match self {
37 InitError::Io(ref err) => std::fmt::Display::fmt(err, f),
38 InitError::NoWaylandLib => f.write_str("could not load libwayland-server.so"),
39 }
40 }
41}
4243/// An error generated when trying to act on an invalid `ObjectId`.
44#[derive(Clone, Debug)]
45pub struct InvalidId;
4647impl std::error::Error for InvalidId {}
4849impl std::fmt::Display for InvalidId {
50#[cfg_attr(coverage, coverage(off))]
51fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
52write!(f, "Invalid Id")
53 }
54}
5556/// Describes why a client has been disconnected from the server.
57#[derive(Debug)]
58pub enum DisconnectReason {
59/// The connection has been closed by the server or client.
60ConnectionClosed,
61/// The server has sent the client a protocol error, terminating the connection.
62ProtocolError(crate::protocol::ProtocolError),
63}
6465/// Holds the client credentials
66#[derive(Debug, Clone, Copy)]
67pub struct Credentials {
68/// pid of the client
69pub pid: rustix::process::RawPid,
70/// uid of the client
71pub uid: rustix::process::RawUid,
72/// gid of the client
73pub gid: rustix::process::RawGid,
74}