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 #[cfg(not(tarpaulin_include))] 24 impl std::error::Error for InitError { cause(&self) -> Option<&dyn std::error::Error>25 fn cause(&self) -> Option<&dyn std::error::Error> { 26 match self { 27 InitError::Io(ref err) => Some(err), 28 InitError::NoWaylandLib => None, 29 } 30 } 31 } 32 33 #[cfg(not(tarpaulin_include))] 34 impl std::fmt::Display for InitError { fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error>35 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> { 36 match 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 } 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 #[cfg(not(tarpaulin_include))] 50 impl std::fmt::Display for InvalidId { fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error>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: nix::libc::pid_t, 70 /// uid of the client 71 pub uid: nix::libc::uid_t, 72 /// gid of the client 73 pub gid: nix::libc::gid_t, 74 } 75