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#![forbid(
44 missing_copy_implementations,
45 missing_debug_implementations,
46 rustdoc::private_doc_tests,
47 //single_use_lifetimes,
48 trivial_casts,
49 trivial_numeric_casts,
50 unreachable_pub,
51 unsafe_code,
52 unused_import_braces,
53 unused_results,
54 clippy::cast_lossless,
55 clippy::needless_pass_by_value,
56)]
57// A list of lints that are only #![deny] and not the stronger #![forbid]. Each one has a comment
58// explaining why it gets the weaker treatment.
59#![deny(
60 // #[derive] generates an #[allow] for this
61 unused_qualifications,
62 // serde's Deserialize/Serialize impls add allows for this
63 rust_2018_idioms,
64 // Not everything in x11rb_protocol::protocol has doc comments
65 missing_docs,
66)]
67#![no_std]
68
69// std crate imports
70extern crate alloc;
71#[cfg(feature = "std")]
72extern crate std;
73
74use alloc::vec::Vec;
75
76pub mod connect;
77pub mod connection;
78#[macro_use]
79pub mod x11_utils;
80pub mod errors;
81pub mod id_allocator;
82pub mod packet_reader;
83pub mod parse_display;
84#[rustfmt::skip]
85#[allow(missing_docs)]
86pub mod protocol;
87#[cfg(feature = "resource_manager")]
88pub mod resource_manager;
89#[cfg(test)]
90mod test;
91mod utils;
92pub mod wrapper;
93pub mod xauth;
94
95pub use utils::RawFdContainer;
96
97// Used to avoid too-complex types.
98/// A combination of a buffer and a list of file descriptors.
99pub type BufWithFds<B> = (B, Vec<RawFdContainer>);
100
101/// Number type used for referring to things that were sent to the server in responses from the
102/// server.
103///
104/// Each request sent to the X11 server is implicitly assigned a monotonically increasing sequence
105/// number. Replies, events, and errors contain the sequence number of the last request that the
106/// server received. This allows to map replies to their requests and to figure out which request
107/// caused an error.
108pub type SequenceNumber = u64;
109
110/// The raw bytes of an event and its sequence number.
111pub type RawEventAndSeqNumber<B> = (B, SequenceNumber);
112
113/// Variants describing which responses to a request should be discarded.
114#[derive(Debug, Copy, Clone, PartialEq, Eq)]
115pub enum DiscardMode {
116 /// Only discard the actual reply. Errors go to the main loop.
117 DiscardReply,
118 /// Ignore any kind of response that this request generates.
119 DiscardReplyAndError,
120}
121