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