| 1 | //! X11 rust bindings. |
| 2 | //! |
| 3 | //! This crate provides a representation of the X11 protocol in Rust. With this protocol, raw X11 |
| 4 | //! bytes can be parsed into a structured representation or raw bytes can be produces. |
| 5 | //! |
| 6 | //! This protocol does not do any I/O. If you need an X11 client library, look at |
| 7 | //! <https://docs.rs/x11rb/latest/x11rb/>. |
| 8 | //! |
| 9 | //! # Feature flags |
| 10 | //! |
| 11 | //! This crate uses [feature |
| 12 | //! flags](https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section) to reduce |
| 13 | //! the amount of compiled code. There are two kinds of feature flags available: |
| 14 | //! |
| 15 | //! * Feature flags for specific X11 extensions |
| 16 | //! * Feature flags for additional functionality |
| 17 | //! |
| 18 | //! ## Feature flags for specific X11 extensions |
| 19 | //! |
| 20 | //! By default, only the core X11 protocol and some small, commonly needed X11 extensions are |
| 21 | //! enabled. These are the `bigreq`, `ge` and `xc_misc` extensions. Further extensions need to be |
| 22 | //! explicitly enabled via their feature flag: |
| 23 | //! |
| 24 | //! `composite`, `damage`, `dpms`, `dri2`, `dri3`, `glx`, `present`, `randr`, `record`, `render`, |
| 25 | //! `res`, `screensaver`, `shape`, `shm`, `sync`, `xevie`, `xf86dri`, `xf86vidmode`, `xfixes`, |
| 26 | //! `xinerama`, `xinput`, `xkb`, `xprint`, `xselinux`, `xtest`, `xv`, `xvmc`. |
| 27 | //! |
| 28 | //! If you want to take the "I do not want to think about this"-approach, you can enable the |
| 29 | //! `all-extensions` feature to just enable, well, all extensions. |
| 30 | //! |
| 31 | //! ## Feature flags for additional functionality |
| 32 | //! |
| 33 | //! Additionally, the following flags exist: |
| 34 | //! * `std` (enabled by default): Enable functionality needing the std library, e.g. environment |
| 35 | //! variables or [`std::os::unix::io::OwnedFd`]. |
| 36 | //! * `resource_manager`: Enable the code in [resource_manager] for loading and querying the |
| 37 | //! X11 resource database. |
| 38 | //! * `serde`: Implement [`serde::Serialize`] and [`serde::Deserialize`] for all objects. |
| 39 | //! * `request-parsing`: Add the ability to parse X11 requests. Not normally needed. |
| 40 | //! * `extra-traits`: Implement extra traits for types. This improves the output of the `Debug` |
| 41 | //! impl and adds `PartialEq`, `Eq`, `PartialOrd`, `Ord`, and `Hash` where possible. |
| 42 | |
| 43 | // A list of lints that are only #![deny] and not the stronger #![forbid]. Each one has a comment |
| 44 | // explaining why it gets the weaker treatment. |
| 45 | #![deny ( |
| 46 | // Contains unreachable_code and "?" generates an #[allow] for this |
| 47 | unused, |
| 48 | // #[derive] generates an #[allow] for this; not part of "unused" |
| 49 | unused_qualifications, |
| 50 | // serde's Deserialize/Serialize impls add allows for this |
| 51 | rust_2018_idioms, |
| 52 | // Not everything in x11rb_protocol::protocol has doc comments |
| 53 | missing_docs, |
| 54 | )] |
| 55 | #![forbid ( |
| 56 | missing_copy_implementations, |
| 57 | missing_debug_implementations, |
| 58 | rustdoc::private_doc_tests, |
| 59 | //single_use_lifetimes, |
| 60 | trivial_casts, |
| 61 | trivial_numeric_casts, |
| 62 | unreachable_pub, |
| 63 | unsafe_code, |
| 64 | unused_must_use, |
| 65 | unused_results, |
| 66 | clippy::cast_lossless, |
| 67 | clippy::needless_pass_by_value, |
| 68 | )] |
| 69 | #![no_std ] |
| 70 | |
| 71 | // std crate imports |
| 72 | extern crate alloc; |
| 73 | #[cfg (feature = "std" )] |
| 74 | extern crate std; |
| 75 | |
| 76 | use alloc::vec::Vec; |
| 77 | |
| 78 | pub mod connect; |
| 79 | pub mod connection; |
| 80 | #[macro_use ] |
| 81 | pub mod x11_utils; |
| 82 | pub mod errors; |
| 83 | pub mod id_allocator; |
| 84 | pub mod packet_reader; |
| 85 | pub mod parse_display; |
| 86 | #[rustfmt::skip] |
| 87 | #[allow (missing_docs)] |
| 88 | pub mod protocol; |
| 89 | #[cfg (feature = "resource_manager" )] |
| 90 | pub mod resource_manager; |
| 91 | #[cfg (test)] |
| 92 | mod test; |
| 93 | mod utils; |
| 94 | pub mod wrapper; |
| 95 | pub mod xauth; |
| 96 | |
| 97 | pub use utils::RawFdContainer; |
| 98 | |
| 99 | // Used to avoid too-complex types. |
| 100 | /// A combination of a buffer and a list of file descriptors. |
| 101 | pub type BufWithFds<B> = (B, Vec<RawFdContainer>); |
| 102 | |
| 103 | /// Number type used for referring to things that were sent to the server in responses from the |
| 104 | /// server. |
| 105 | /// |
| 106 | /// Each request sent to the X11 server is implicitly assigned a monotonically increasing sequence |
| 107 | /// number. Replies, events, and errors contain the sequence number of the last request that the |
| 108 | /// server received. This allows to map replies to their requests and to figure out which request |
| 109 | /// caused an error. |
| 110 | pub type SequenceNumber = u64; |
| 111 | |
| 112 | /// The raw bytes of an event and its sequence number. |
| 113 | pub type RawEventAndSeqNumber<B> = (B, SequenceNumber); |
| 114 | |
| 115 | /// Variants describing which responses to a request should be discarded. |
| 116 | #[derive (Debug, Copy, Clone, PartialEq, Eq)] |
| 117 | pub enum DiscardMode { |
| 118 | /// Only discard the actual reply. Errors go to the main loop. |
| 119 | DiscardReply, |
| 120 | /// Ignore any kind of response that this request generates. |
| 121 | DiscardReplyAndError, |
| 122 | } |
| 123 | |