about summary refs log tree commit diff
path: root/src/error.rs
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-11-14 03:17:45 -0700
committerIrene Knapp <ireneista@irenes.space>2026-11-14 03:17:45 -0700
commit5b488f558ccaca6ac35edda0366d74b9126285e3 (patch)
treec55ea2aa863fa18574d9d99bdc8922a61d945814 /src/error.rs
parent815fb567bdfdbc3901148a4b9f49fd42a56c4f27 (diff)
use futures-lite and async-io
these are from smol, but we don't need all of smol

it's a kinda upsetting quantity of transitive dependencies :( but oh well

Force-Push: yes
Change-Id: I84d638b4866adf7f68401f6065c7ab358d3e7892
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs
new file mode 100644
index 0000000..81c69e5
--- /dev/null
+++ b/src/error.rs
@@ -0,0 +1,35 @@
+use std::fmt::{ self, Display };
+
+#[derive(Debug)]
+pub struct Error(String);
+pub type Result<T> = std::result::Result<T, Error>;
+
+
+impl Display for Error {
+  fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
+    write!(formatter, "Error: {}", self.0)
+  }
+}
+
+impl From<xcb::Error> for Error {
+  fn from(error: xcb::Error) -> Error {
+    match error {
+      xcb::Error::Connection(error) => error.into(),
+      xcb::Error::Protocol(error) => error.into(),
+    }
+  }
+}
+
+impl From<xcb::ConnError> for Error {
+  fn from(error: xcb::ConnError) -> Error {
+    Error(format!("X connection: {}", error))
+  }
+}
+
+impl From<xcb::ProtocolError> for Error {
+  fn from(error: xcb::ProtocolError) -> Error {
+    Error(format!("X protocol: {}", error))
+  }
+}
+
+