Skip to content
This repository has been archived by the owner on Nov 12, 2023. It is now read-only.

Commit

Permalink
XRBK macro: specify traits for hide attributes (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
Antikyth authored Jan 22, 2023
2 parents 20d4f8f + 29bc1e9 commit 46502d9
Show file tree
Hide file tree
Showing 9 changed files with 244 additions and 66 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ bitflags = "1.3" # bit masks - representations of masks
thiserror = "1" # error handling
derive_more = "0.99" # derive more useful traits
xrbk_macro = { path = "./xrbk_macro" } # generation of XRB structures
derivative = "2.2.0"
69 changes: 52 additions & 17 deletions src/x11/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
use crate::message::Error;

use derivative::Derivative;
use xrbk_macro::derive_xrb;
extern crate self as xrb;

derive_xrb! {
#[derive(Debug, Hash, Writable, Readable, X11Size)]
#[derive(Debug, Derivative, Writable, Readable, X11Size)]
#[derivative(Hash, PartialEq, Eq)]
/// An [error] generated when the [major opcode] and [minor opcode]
/// combination provided in a [request] does not specify a valid [request].
///
Expand All @@ -27,6 +29,7 @@ derive_xrb! {
/// [minor opcode]: crate::message::Request::MINOR_OPCODE
pub struct Request: Error(1) {
#[sequence]
#[derivative(PartialEq = "ignore", Hash = "ignore")]
/// The sequence number identifying the [request] that was
/// sent.
///
Expand Down Expand Up @@ -61,7 +64,8 @@ derive_xrb! {
[_; ..],
}

#[derive(Debug, Hash, Writable, Readable, X11Size)]
#[derive(Debug, Derivative, Writable, Readable, X11Size)]
#[derivative(Hash, PartialEq, Eq)]
/// An [error] generated when a numerical value contained in the [request]
/// falls outside of the range of accepted values.
///
Expand All @@ -72,6 +76,7 @@ derive_xrb! {
/// [error]: Error
pub struct Value: Error(2) {
#[sequence]
#[derivative(PartialEq = "ignore", Hash = "ignore")]
/// The sequence number identifying the [request] that was
/// sent.
///
Expand Down Expand Up @@ -108,7 +113,8 @@ derive_xrb! {
[_; ..],
}

#[derive(Debug, Hash, Writable, Readable, X11Size)]
#[derive(Debug, Derivative, Writable, Readable, X11Size)]
#[derivative(Hash, PartialEq, Eq)]
/// An [error] generated when the [`Window`] ID used in the [request] does
/// not refer to a defined [window].
///
Expand All @@ -118,6 +124,7 @@ derive_xrb! {
/// [request]: crate::message::Request
pub struct Window: Error(3) {
#[sequence]
#[derivative(PartialEq = "ignore", Hash = "ignore")]
/// The sequence number identifying the [request] that was
/// sent.
///
Expand Down Expand Up @@ -154,7 +161,8 @@ derive_xrb! {
[_; ..],
}

#[derive(Debug, Hash, Writable, Readable, X11Size)]
#[derive(Debug, Derivative, Writable, Readable, X11Size)]
#[derivative(Hash, PartialEq, Eq)]
/// An [error] generated when the [`Pixmap`] ID used in the [request] does
/// not refer to a defined [pixmap].
///
Expand All @@ -164,6 +172,7 @@ derive_xrb! {
/// [request]: crate::message::Request
pub struct Pixmap: Error(4) {
#[sequence]
#[derivative(PartialEq = "ignore", Hash = "ignore")]
/// The sequence number identifying the [request] that was
/// sent.
///
Expand Down Expand Up @@ -200,7 +209,8 @@ derive_xrb! {
[_; ..],
}

#[derive(Debug, Hash, Writable, Readable, X11Size)]
#[derive(Debug, Derivative, Writable, Readable, X11Size)]
#[derivative(Hash, PartialEq, Eq)]
/// An [error] generated when the [`Atom`] ID used in the [request] does
/// not refer to a defined [atom].
///
Expand All @@ -210,6 +220,7 @@ derive_xrb! {
/// [request]: crate::message::Request
pub struct Atom: Error(5) {
#[sequence]
#[derivative(PartialEq = "ignore", Hash = "ignore")]
/// The sequence number identifying the [request] that was
/// sent.
///
Expand Down Expand Up @@ -246,7 +257,8 @@ derive_xrb! {
[_; ..],
}

#[derive(Debug, Hash, Writable, Readable, X11Size)]
#[derive(Debug, Derivative, Writable, Readable, X11Size)]
#[derivative(Hash, PartialEq, Eq)]
/// An [error] generated when the [`CursorAppearance`] ID used in the
/// [request] does not refer to a defined [cursor appearance].
///
Expand All @@ -256,6 +268,7 @@ derive_xrb! {
/// [request]: crate::message::Request
pub struct CursorAppearance: Error(6) {
#[sequence]
#[derivative(PartialEq = "ignore", Hash = "ignore")]
/// The sequence number identifying the [request] that was
/// sent.
///
Expand Down Expand Up @@ -293,7 +306,8 @@ derive_xrb! {
[_; ..],
}

#[derive(Debug, Hash, Writable, Readable, X11Size)]
#[derive(Debug, Derivative, Writable, Readable, X11Size)]
#[derivative(Hash, PartialEq, Eq)]
/// An [error] generated when the [`Font`] ID used in the [request] does
/// not refer to a defined [font].
///
Expand All @@ -303,6 +317,7 @@ derive_xrb! {
/// [request]: crate::message::Request
pub struct Font: Error(7) {
#[sequence]
#[derivative(PartialEq = "ignore", Hash = "ignore")]
/// The sequence number identifying the [request] that was
/// sent.
///
Expand Down Expand Up @@ -339,7 +354,8 @@ derive_xrb! {
[_; ..],
}

#[derive(Debug, Hash, Writable, Readable, X11Size)]
#[derive(Debug, Derivative, Writable, Readable, X11Size)]
#[derivative(Hash, PartialEq, Eq)]
/// An [error] generated when there is a mismatch of some kind.
///
/// This [error] is generated for a number of reasons:
Expand All @@ -358,6 +374,7 @@ derive_xrb! {
/// [graphics context]: crate::GraphicsContext
pub struct Match: Error(8) {
#[sequence]
#[derivative(PartialEq = "ignore", Hash = "ignore")]
/// The sequence number identifying the [request] that was
/// sent.
///
Expand All @@ -384,7 +401,8 @@ derive_xrb! {
[_; ..],
}

#[derive(Debug, Hash, Writable, Readable, X11Size)]
#[derive(Debug, Derivative, Writable, Readable, X11Size)]
#[derivative(Hash, PartialEq, Eq)]
/// An [error] generated when the [`Drawable`] ID used in the [request]
/// does not refer to a defined [window] or [pixmap].
///
Expand All @@ -395,6 +413,7 @@ derive_xrb! {
/// [request]: crate::message::Request
pub struct Drawable: Error(9) {
#[sequence]
#[derivative(PartialEq = "ignore", Hash = "ignore")]
/// The sequence number identifying the [request] that was
/// sent.
///
Expand Down Expand Up @@ -432,7 +451,8 @@ derive_xrb! {
[_; ..],
}

#[derive(Debug, Hash, Writable, Readable, X11Size)]
#[derive(Debug, Derivative, Writable, Readable, X11Size)]
#[derivative(Hash, PartialEq, Eq)]
/// An [error] generated when access is not allowed for what the [request] is
/// trying to do.
///
Expand All @@ -459,6 +479,7 @@ derive_xrb! {
/// [colormap]: crate::Colormap
pub struct Access: Error(10) {
#[sequence]
#[derivative(PartialEq = "ignore", Hash = "ignore")]
/// The sequence number identifying the [request] that was
/// sent.
///
Expand All @@ -485,13 +506,15 @@ derive_xrb! {
[_; ..],
}

#[derive(Debug, Hash, Writable, Readable, X11Size)]
#[derive(Debug, Derivative, Writable, Readable, X11Size)]
#[derivative(Hash, PartialEq, Eq)]
/// An [error] generated when the X server failed to allocate the requested
/// resource.
///
/// [error]: Error
pub struct Alloc: Error(11) {
#[sequence]
#[derivative(PartialEq = "ignore", Hash = "ignore")]
/// The sequence number identifying the [request] that was
/// sent.
///
Expand All @@ -518,7 +541,8 @@ derive_xrb! {
[_; ..],
}

#[derive(Debug, Hash, Writable, Readable, X11Size)]
#[derive(Debug, Derivative, Writable, Readable, X11Size)]
#[derivative(Hash, PartialEq, Eq)]
/// An [error] generated when the [`Colormap`] ID used in the [request]
/// does not refer to a defined [colormap].
///
Expand All @@ -528,6 +552,7 @@ derive_xrb! {
/// [request]: crate::message::Request
pub struct Colormap: Error(12) {
#[sequence]
#[derivative(PartialEq = "ignore", Hash = "ignore")]
/// The sequence number identifying the [request] that was
/// sent.
///
Expand Down Expand Up @@ -564,7 +589,8 @@ derive_xrb! {
[_; ..],
}

#[derive(Debug, Hash, Writable, Readable, X11Size)]
#[derive(Debug, Derivative, Writable, Readable, X11Size)]
#[derivative(Hash, PartialEq, Eq)]
/// An [error] generated when the [`GraphicsContext`] ID used in the [request]
/// does not refer to a defined [graphics context].
///
Expand All @@ -574,6 +600,7 @@ derive_xrb! {
/// [request]: crate::message::Request
pub struct GraphicsContext: Error(13) {
#[sequence]
#[derivative(PartialEq = "ignore", Hash = "ignore")]
/// The sequence number identifying the [request] that was
/// sent.
///
Expand Down Expand Up @@ -610,13 +637,15 @@ derive_xrb! {
[_; ..],
}

#[derive(Debug, Hash, Writable, Readable, X11Size)]
#[derive(Debug, Derivative, Writable, Readable, X11Size)]
#[derivative(Hash, PartialEq, Eq)]
/// An [error] generated when a chosen resource ID is not in the range of
/// resource IDs assigned to the client, or the ID is already in use.
///
/// [error]: Error
pub struct ResourceIdChoice: Error(14) {
#[sequence]
#[derivative(PartialEq = "ignore", Hash = "ignore")]
/// The sequence number identifying the [request] that was
/// sent.
///
Expand Down Expand Up @@ -648,7 +677,8 @@ derive_xrb! {
[_; ..],
}

#[derive(Debug, Hash, Writable, Readable, X11Size)]
#[derive(Debug, Derivative, Writable, Readable, X11Size)]
#[derivative(Hash, PartialEq, Eq)]
/// An [error] generated when the [request] specifies the name of a [font]
/// or color which does not exist.
///
Expand All @@ -657,6 +687,7 @@ derive_xrb! {
/// [font]: crate::Font
pub struct Name: Error(15) {
#[sequence]
#[derivative(PartialEq = "ignore", Hash = "ignore")]
/// The sequence number identifying the [request] that was
/// sent.
///
Expand All @@ -683,7 +714,8 @@ derive_xrb! {
[_; ..],
}

#[derive(Debug, Hash, Writable, Readable, X11Size)]
#[derive(Debug, Derivative, Writable, Readable, X11Size)]
#[derivative(Hash, PartialEq, Eq)]
/// An [error] generated when a [request] is not of the correct length.
///
/// The length may be too short or too long to hold the fields defined for
Expand All @@ -694,6 +726,7 @@ derive_xrb! {
/// [request]: crate::message::Request
pub struct Length: Error(16) {
#[sequence]
#[derivative(PartialEq = "ignore", Hash = "ignore")]
/// The sequence number identifying the [request] that was
/// sent.
///
Expand All @@ -720,14 +753,16 @@ derive_xrb! {
[_; ..],
}

#[derive(Debug, Hash, Writable, Readable, X11Size)]
#[derive(Debug, Derivative, Writable, Readable, X11Size)]
#[derivative(Hash, PartialEq, Eq)]
/// An [error] generated when the X server does not implement some aspect
/// of the [request].
///
/// [error]: Error
/// [request]: crate::message::Request
pub struct Implementation: Error(17) {
#[sequence]
#[derivative(PartialEq = "ignore", Hash = "ignore")]
/// The sequence number identifying the [request] that was
/// sent.
///
Expand Down
Loading

0 comments on commit 46502d9

Please sign in to comment.