pub use x11rb_protocol::x11_utils::{
parse_request_header, BigRequests, ExtInfoProvider, ExtensionInformation, ReplyParsingFunction,
Request, RequestHeader, Serialize, TryParse, TryParseFd, X11Error,
};
#[macro_export]
macro_rules! atom_manager {
{
$(#[$struct_meta:meta])*
$vis:vis $struct_name:ident:
$(#[$cookie_meta:meta])*
$cookie_name:ident {
$($field_name:ident$(: $atom_value:expr)?,)*
}
} => {
#[allow(non_snake_case)]
#[derive(Debug)]
$(#[$cookie_meta])*
$vis struct $cookie_name<'a, C: $crate::protocol::xproto::ConnectionExt> {
__private_phantom: ::std::marker::PhantomData<&'a C>,
__private_cookies: ::std::vec::Vec<$crate::cookie::Cookie<'a, C, $crate::protocol::xproto::InternAtomReply>>,
}
#[allow(non_snake_case)]
#[derive(Debug, Clone, Copy)]
$(#[$struct_meta])*
$vis struct $struct_name {
$(
$vis $field_name: $crate::protocol::xproto::Atom,
)*
}
impl $struct_name {
$vis fn new<C: $crate::protocol::xproto::ConnectionExt>(
_conn: &C,
) -> ::std::result::Result<$cookie_name<'_, C>, $crate::errors::ConnectionError> {
let names = [
$($crate::__atom_manager_atom_value!($field_name$(: $atom_value)?),)*
];
let cookies: ::std::result::Result<::std::vec::Vec<_>, _>
= names.into_iter().map(|name| _conn.intern_atom(false, name)).collect();
Ok($cookie_name {
__private_phantom: ::std::marker::PhantomData,
__private_cookies: cookies?,
})
}
}
impl<'a, C: $crate::protocol::xproto::ConnectionExt> $cookie_name<'a, C> {
$vis fn reply(self) -> ::std::result::Result<$struct_name, $crate::errors::ReplyError> {
let mut replies = self.__private_cookies.into_iter();
Ok($struct_name {
$(
$field_name: replies.next().expect("new() should have constructed a Vec of the correct size").reply()?.atom,
)*
})
}
}
}
}
#[doc(hidden)]
#[macro_export]
macro_rules! __atom_manager_atom_value {
($field_name:ident) => {
stringify!($field_name).as_bytes()
};
($field_name:ident: $atom_value:expr) => {
$atom_value
};
}