1#![no_std]
24#![allow(clippy::uninlined_format_args, clippy::too_many_arguments)]
25#![cfg_attr(not(feature = "xlib-client"), forbid(unsafe_code))]
26#![forbid(future_incompatible)]
27
28extern crate alloc;
29
30#[cfg(feature = "std")]
31extern crate std;
32
33#[cfg(feature = "client")]
34mod client;
35#[cfg(feature = "server")]
36mod server;
37
38#[cfg(any(feature = "x11rb-server", feature = "x11rb-client"))]
39pub mod x11rb;
40#[cfg(feature = "xlib-client")]
41pub mod xlib;
42
43#[cfg(feature = "client")]
44pub use crate::client::{Client, ClientError, ClientHandler};
45
46#[cfg(feature = "server")]
47pub const ALL_LOCALES: &str = include_str!("./all_locales.txt");
48
49#[cfg(feature = "server")]
50pub use crate::server::{
51 InputContext, InputMethod, Server, ServerCore, ServerError, ServerHandler, UserInputContext,
52 XimConnection, XimConnections,
53};
54pub type AHashMap<K, V> = hashbrown::HashMap<K, V, ahash::RandomState>;
55pub use xim_parser::*;
56
57#[allow(non_snake_case, dead_code)]
58struct Atoms<Atom> {
59 XIM_SERVERS: Atom,
60 LOCALES: Atom,
61 TRANSPORT: Atom,
62 XIM_XCONNECT: Atom,
63 XIM_PROTOCOL: Atom,
64}
65
66impl<Atom> Atoms<Atom> {
67 #[allow(unused)]
68 pub fn new<E, F>(f: F) -> Result<Self, E>
69 where
70 F: Fn(&'static str) -> Result<Atom, E>,
71 {
72 Ok(Self {
73 XIM_SERVERS: f("XIM_SERVERS")?,
74 LOCALES: f("LOCALES")?,
75 TRANSPORT: f("TRANSPORT")?,
76 XIM_XCONNECT: f("_XIM_XCONNECT")?,
77 XIM_PROTOCOL: f("_XIM_PROTOCOL")?,
78 })
79 }
80
81 #[allow(unused)]
82 pub fn new_null<E, F>(f: F) -> Result<Self, E>
83 where
84 F: Fn(&'static str) -> Result<Atom, E>,
85 {
86 Ok(Self {
87 XIM_SERVERS: f("XIM_SERVERS\0")?,
88 LOCALES: f("LOCALES\0")?,
89 TRANSPORT: f("TRANSPORT\0")?,
90 XIM_XCONNECT: f("_XIM_XCONNECT\0")?,
91 XIM_PROTOCOL: f("_XIM_PROTOCOL\0")?,
92 })
93 }
94}